From 3c138c72f6f0686282089cd75de13a79f6681d22 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Mon, 24 Jan 2022 08:17:31 -0500 Subject: [PATCH] Return to pre-gist method of spell check (#409) * Return to pre-gist method of spell check * Get rid of gist stuff on delete-preview too * Temporarily add spelling errors to test * Commit before testing * Switch to use -z * Fix git diff step * Just look at the local main since it should be up to date * make it simple * Get rid of double bracket * No brackets? * Revert "Temporarily add spelling errors to test" This reverts commit 9e9a9325527142c377bb27a1dfeb040f0859f0dd. --- .github/workflows/delete-preview.yml | 12 --------- .github/workflows/render-preview.yml | 9 ++++--- .github/workflows/style-and-sp-check.yml | 33 +++++++++++++----------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/.github/workflows/delete-preview.yml b/.github/workflows/delete-preview.yml index 642fea0a..b910ad45 100644 --- a/.github/workflows/delete-preview.yml +++ b/.github/workflows/delete-preview.yml @@ -22,15 +22,3 @@ jobs: with: github_token: ${{ secrets.GH_PAT }} branches: preview-${{ github.event.pull_request.number }} - - - name: Delete gist - id: gist - run: | - echo ${{ secrets.GH_PAT }} > docker/git_token.txt - gist_key=${GITHUB_REPOSITORY}_spell_check_${{ github.event.pull_request.number }} - gist_url=$(Rscript --vanilla scripts/get_the_gist.R \ - --git_pat docker/git_token.txt \ - --gist_key $gist_key \ - --file resources/spell_check_results.tsv \ - --delete) - rm docker/git_token.txt diff --git a/.github/workflows/render-preview.yml b/.github/workflows/render-preview.yml index a21c7984..09f26c41 100644 --- a/.github/workflows/render-preview.yml +++ b/.github/workflows/render-preview.yml @@ -56,15 +56,16 @@ jobs: - name: Commit rendered bookdown files to preview branch id: commit run: | - changes=$(git diff --name-only `git log --format="%H" -n 1 origin/main` -- docs) + changes=$(git diff --name-only -- docs) - if [[ -n $changes ]]; then + if -z $changes + then + echo ::set-output name=changes::$(echo 'no_changes') + else echo ::set-output name=changes::$(echo 'changes') git add . --force git commit -m 'Render bookdown preview' git push --force origin "preview-${{ github.event.pull_request.number }}" - else - echo ::set-output name=changes::$(echo 'no_changes') fi - name: Find Comment diff --git a/.github/workflows/style-and-sp-check.yml b/.github/workflows/style-and-sp-check.yml index 67b22215..71fcf5d3 100644 --- a/.github/workflows/style-and-sp-check.yml +++ b/.github/workflows/style-and-sp-check.yml @@ -1,4 +1,3 @@ - # Candace Savonen Dec 2021 name: Style and spell check R markdowns @@ -34,30 +33,35 @@ jobs: results=$(Rscript "scripts/spell-check.R") echo "::set-output name=sp_chk_results::$results" cat resources/spell_check_results.tsv - - name: Archive spelling errors uses: actions/upload-artifact@v2 with: name: spell-check-results path: resources/spell_check_results.tsv - - name: Upload to Gist - id: gist + - name: Spell check errors run: | - echo ${{ secrets.GH_PAT }} > docker/git_token.txt - gist_key=${GITHUB_REPOSITORY}_spell_check_${{ github.event.pull_request.number }} - gist_url=$(Rscript --vanilla scripts/get_the_gist.R \ - --git_pat docker/git_token.txt \ - --gist_key $gist_key \ - --file resources/spell_check_results.tsv) - echo "::set-output name=gist_url::$gist_url" - rm docker/git_token.txt + # Get on the preview branch if it exists. If it doesn't create it. + branch_name='preview-${{ github.event.pull_request.number }}' + git rev-parse --quiet --verify $branch_name >/dev/null && exists=true || exists=false + if $exists == true + then + git checkout $branch_name + git pull --set-upstream origin $branch_name --allow-unrelated-histories + else + git checkout -b $branch_name + fi + git add --force resources/spell_check_results.tsv + git commit -m 'Add spell check file' + git push --force --set-upstream origin $branch_name - name: Build components of the spell check comment id: build-components env: GH_PAT: ${{ secrets.GH_PAT }} run: | + branch_name='preview-${{ github.event.pull_request.number }}' + sp_error_url=https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/$branch_name/resources/spell_check_results.tsv echo ::set-output name=time::$(date +'%Y-%m-%d') echo ::set-output name=commit_id::$GITHUB_SHA echo ::set-output name=sp_error_url::$sp_error_url @@ -79,8 +83,7 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body: | :warning: There are spelling errors that need to be addressed. [Read this guide for more info](https://github.com/jhudsl/OTTR_Template/wiki/Spell-check). - - [Download the errors here.](${{ steps.gist.outputs.gist_url }}) + [Download the errors here.](${{ steps.build-components.outputs.sp_error_url }}) _Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ edit-mode: replace @@ -96,7 +99,6 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body: | No spelling errors! :tada: - _Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ edit-mode: replace @@ -106,5 +108,6 @@ jobs: - name: Commit styled files run: | git add \*.Rmd + git add resources/spell_check_results.tsv git commit -m 'Style Rmds' || echo "No changes to commit" git push origin || echo "No changes to commit"