File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Auto-fix file format
2+
3+ # Since pre-commit.ci cannot run local hooks, run them here manually to fixup formatting in pull requests
4+
5+ on : pull_request
6+
7+ env :
8+ # SSH Deploy Key with write access (needed to trigger push workflow runs in created pull request)
9+ SSH_KEY : ${{ secrets.SSH_KEY_GITHUB_ACTION }}
10+
11+ jobs :
12+ pre-commit :
13+ name : Format files with pre-commit
14+ runs-on : windows-2025
15+ steps :
16+ - uses : actions/checkout@v5
17+ with :
18+ ssh-key : ${{ env.SSH_KEY }}
19+ fetch-depth : 0
20+
21+ - name : Bot setup
22+ run : |
23+ AUTHOR=$(git log -1 --pretty=%an)
24+ if [ "$AUTHOR" == "Bot" ]; then
25+ echo "Commit made by bot, skipping further steps in the pipeline."
26+ exit 0
27+ fi
28+ git config user.name "Bot"
29+ git config user.email "<action@github.com>"
30+
31+ - name : Format files
32+ continue-on-error : true
33+ id : check
34+ run : |
35+ FILES=$(git diff --name-only HEAD origin/$GITHUB_BASE_REF | tr '\n' ' ')
36+ echo $FILES
37+ pre-commit run --files $FILES
38+
39+ - name : Push formatting fixes
40+ if : steps.check.outcome == 'failure'
41+ run : |
42+ git commit -am "Fixes formatting"
43+ git push origin HEAD:${{github.event.pull_request.head.ref}}
You can’t perform that action at this time.
0 commit comments