Skip to content

Commit ce6e788

Browse files
committed
Gentle failure of formatting action
1 parent 105399f commit ce6e788

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/workflows/format.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ jobs:
2222
run: pip install black
2323
- name: If needed, commit black changes to the pull request
2424
run: |
25-
black .
26-
git config --global user.name 'formatting'
27-
git config --global user.email 'mikeheddes@users.noreply.github.com'
28-
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
29-
git checkout $GITHUB_HEAD_REF
30-
git commit -am "Format Python code"
31-
git push
25+
if black --check .
26+
then
27+
echo "nothing to do"
28+
else
29+
black .
30+
git config --global user.name 'formatting'
31+
git config --global user.email 'mikeheddes@users.noreply.github.com'
32+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
33+
git checkout $GITHUB_HEAD_REF
34+
git commit -am "Format Python code"
35+
git push
36+
fi

0 commit comments

Comments
 (0)