Skip to content

Commit d455fed

Browse files
committed
j
1 parent c889b74 commit d455fed

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

.github/workflows/format.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,36 @@ jobs:
1313
name: Format files with pre-commit
1414
runs-on: ubuntu-24.04
1515
steps:
16+
1617
- uses: actions/checkout@v4
1718
with:
1819
ssh-key: ${{ env.SSH_KEY }}
1920
fetch-depth: 0
2021

21-
- name: Skip if bot
22+
- name: Install python
23+
uses: actions/setup-python@v3
24+
25+
- name: Fix formatting
26+
continue-on-error: true
27+
id: format
2228
run: |
2329
git checkout ${{github.event.pull_request.head.ref}}
24-
git log -1
30+
# Skip for commits created by bots (such as me)
2531
AUTHOR=$(git log -1 --pretty="%an %ae")
26-
echo ">$AUTHOR<"
2732
if [[ $AUTHOR =~ [Bb]ot ]]; then
28-
echo "Commit made by bot, skipping further steps in the pipeline."
33+
echo "Commit made by $AUTHOR, skipping further steps in the pipeline."
2934
exit 0
3035
fi
31-
32-
- name: Install python
33-
uses: actions/setup-python@v3
34-
35-
- name: Install pre-commit
36-
run: |
36+
# Install pre-commit
3737
python3 -m pip install pre-commit
3838
pre-commit install
39-
40-
- name: Format files
41-
continue-on-error: true
42-
id: check
43-
run: |
44-
FILES=$(git diff --name-only HEAD origin/$GITHUB_BASE_REF | tr '\n' ' ')
45-
echo $FILES
46-
pre-commit run --files $FILES
39+
# Format files
40+
FILES=$(git diff --name-only HEAD origin/$GITHUB_BASE_REF | tr '\n' ' ')
41+
echo $FILES
42+
pre-commit run --files $FILES # non-zero exit code if files were modified
4743
4844
- name: Push formatted fixes
49-
if: steps.check.outcome == 'failure'
45+
if: steps.format.outcome == 'failure'
5046
run: |
5147
git config user.name "Bot"
5248
git config user.email "<[email protected]>"

0 commit comments

Comments
 (0)