Update github actions to use 1password #698
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Style and spell check R markdowns | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
pull_request: | |
branches: [ staging, master ] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "style and check" | |
style-n-check: | |
runs-on: ubuntu-latest | |
container: | |
image: rocker/tidyverse:4.0.5 | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- name: Install curl | |
run: apt-get update && apt-get install -y --no-install-recommends curl | |
- name: Load 1Password secrets | |
uses: 1password/load-secrets-action@v1 | |
with: | |
export-env: true | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TRAINING_OP_SERVICE_ACCOUNT_TOKEN }} | |
DOCS_BOT_GITHUB_TOKEN: ${{ secrets.OP_DOCS_BOT_GITHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# What branch to commit to: the one from the pull request | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
token: ${{ env.DOCS_BOT_GITHUB_TOKEN }} | |
- name: Configure git | |
run: | | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
- name: Install packages | |
run: Rscript -e "install.packages(c('styler', 'spelling'))" | |
- name: Run spell check | |
id: spell_check_run | |
run: | | |
results=$(Rscript "scripts/spell-check.R") | |
echo "sp_chk_results=$results" >> "$GITHUB_OUTPUT" | |
cat spell_check_results.tsv | |
- name: Archive spelling errors | |
uses: actions/upload-artifact@v3 | |
with: | |
name: spell-check-results | |
path: spell_check_results.tsv | |
# If there are too many spelling errors, this will stop the workflow | |
- name: Check spell check results - fail if too many errors | |
if: ${{ steps.spell_check_run.outputs.sp_chk_results > 3 }} | |
run: exit 1 | |
- name: Run styler | |
run: Rscript -e "styler::style_file(list.files(pattern = 'Rmd$', recursive = TRUE, full.names = TRUE));warnings()" | |
- name: Commit | |
run: | | |
git add \*.Rmd | |
git commit -m 'Style Rmds' || echo "No changes to commit" | |
git push origin || echo "No changes to commit" |