Skip to content

Commit

Permalink
CI | Enhance pre-commit-autoupdate workflow
Browse files Browse the repository at this point in the history
So it only pushes to the origin if there are really any updates.

Signed-off-by: MichaIng <micha@dietpi.com>
  • Loading branch information
MichaIng committed Mar 28, 2024
1 parent 6143d82 commit ff6d2e6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,22 @@ jobs:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch --all
git checkout -B pre-commit-autoupdate
branch_exists=0
git fetch origin pre-commit-autoupdate && branch_exists=1
if (( branch_exists ))
then
git switch pre-commit-autoupdate
else
git checkout -b pre-commit-autoupdate
fi
pip install pre-commit
pre-commit --version
pre-commit autoupdate
git diff --exit-code && exit 0
git add -A
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
if git ls-remote -h --exit-code origin pre-commit-autoupdate
if (( branch_exists ))
then
git commit --amend --no-edit
git push -f origin pre-commit-autoupdate
Expand Down

0 comments on commit ff6d2e6

Please sign in to comment.