Skip to content

Commit

Permalink
Return to pre-gist method of spell check (#409)
Browse files Browse the repository at this point in the history
* 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 9e9a932.
  • Loading branch information
cansavvy authored Jan 24, 2022
1 parent 99cc9ff commit 3c138c7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/delete-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions .github/workflows/render-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 18 additions & 15 deletions .github/workflows/style-and-sp-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Candace Savonen Dec 2021

name: Style and spell check R markdowns
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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"

0 comments on commit 3c138c7

Please sign in to comment.