Open Justin-JHG opened 1 year ago
update, this is similar to issue #38
so this github action does support only check input list of files, for example only the files changed in the current pull request.
I did make it work and will attach my full workflow below, before that I will list the issues with this Github Action:
the list of files passed into the path
option needs to be space seperated instead of comma seperated, if using comma seperetd then the codespell would only check the last file in the list.
e.g. it needs to be ./dir1/file1 ./dir2/file2
instead of ./dir1/file1, ./dir2/file2
so the workflow in the current repo to test the path option doesn't work, and it will ignore README.md by default
the skip option by default is skipping ./.git
instead of what advised as skipping nothing, so I had to hack it to say: skip: nothing
exected:
actual:
hope this helps anyone want to use this action for the same purpose, thanks
name: 🚥 Codespell
# workflow to check spelling errors on the changed files within the current pull request
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 🔸 Get Changed Files from Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# get file names and seperate them with space ' '
files=$(gh pr diff ${{ github.event.pull_request.number }} --name-only | xargs -I {} sh -c 'echo "./{}"' | tr '\n' ' ')
echo "CHANGED_FILES=$files" >> "$GITHUB_ENV"
- name: 🔸 Output Changed Files
run: echo ${{ env.CHANGED_FILES }}
- name: 🔸 Check for Spelling Errors for Changed Files
uses: codespell-project/actions-codespell@v1
with:
check_filenames: true
skip: nothing
path: ${{ env.CHANGED_FILES }}
Thanks for documenting your workflow, I came here to suggest the same feature and could use your insights to implement the same in https://github.com/godotengine/godot/pull/76828.
Hi is it possible to add an option so that this action only checks files changed in the current pull request?
thanks