fix: Avoid crash when file in repo contains non-unicode characters #214
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: 'Fix Style' | |
on: | |
issue_comment: | |
types: [created] | |
pull_request_target: | |
jobs: | |
fix-style: | |
if: | | |
github.repository_owner == 'rapidsai' && | |
( | |
github.event_name == 'pull_request_target' || | |
( | |
github.event_name == 'issue_comment' && | |
github.event.issue.pull_request && | |
startsWith(github.event.comment.body, '/fix style') | |
) | |
) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get PR Information | |
id: pr-info | |
run: | | |
set -x | |
PR_NUM=${{ github.event.number || github.event.issue.number }} | |
echo "PR_INFO=$(gh -R ${{ github.repository }} pr view ${PR_NUM} --json headRepository,headRepositoryOwner,headRefName | jq -c)" >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v3 | |
with: | |
repository: '${{ fromJSON(steps.pr-info.outputs.PR_INFO).headRepositoryOwner.login }}/${{ fromJSON(steps.pr-info.outputs.PR_INFO).headRepository.name }}' | |
ref: '${{ fromJSON(steps.pr-info.outputs.PR_INFO).headRefName }}' | |
- uses: actions/setup-python@v4 | |
- run: python -m pip install pre-commit | |
- run: pre-commit run --all-files --show-diff-on-failure --color=always | |
- uses: EndBug/add-and-commit@v9 | |
# Only commit changes if triggered by a comment starting with '/fix style' | |
if: | | |
failure() && | |
github.event_name == 'issue_comment' && | |
github.event.issue.pull_request && | |
startsWith(github.event.comment.body, '/fix style') | |
with: | |
fetch: false | |
message: 'Fix style.' |