@@ -38,20 +38,35 @@ jobs:
3838 with :
3939 fetch-depth : 0
4040
41+ - name : Check if last commit was auto-format
42+ if : steps.check_enabled.outputs.enabled == 'true'
43+ id : check_loop
44+ run : |
45+ LAST_COMMIT_MSG=$(git log -1 --pretty=%B)
46+ LAST_COMMIT_AUTHOR=$(git log -1 --pretty=%an)
47+
48+ if [[ "$LAST_COMMIT_MSG" == *"auto-format code"* ]] || [[ "$LAST_COMMIT_AUTHOR" == "github-actions[bot]" ]]; then
49+ echo "skip=true" >> $GITHUB_OUTPUT
50+ echo "⏭️ Skipping: Last commit was an auto-format"
51+ exit 0
52+ else
53+ echo "skip=false" >> $GITHUB_OUTPUT
54+ fi
55+
4156 - name : Install PHP dependencies
4257 if : steps.check_enabled.outputs.enabled == 'true'
4358 uses : ./.github/actions/composer-install
4459 with :
4560 cache-version : ${{ secrets.CACHE_VERSION }}
4661
4762
48- - name : Run code formatter
49- if : steps.check_enabled.outputs.enabled == 'true'
63+ - name : Format Code
64+ if : steps.check_enabled.outputs.enabled == 'true' && steps.check_loop.outputs.skip != 'true'
5065 run : |
5166 ./vendor/bin/pint --parallel --diff=${{ github.base_ref || github.ref_name }}
5267
5368 - name : Check for changes
54- if : steps.check_enabled.outputs.enabled == 'true'
69+ if : steps.check_enabled.outputs.enabled == 'true' && steps.check_loop.outputs.skip != 'true'
5570 id : check_changes
5671 run : |
5772 if [[ -n $(git status -s) ]]; then
6378 fi
6479
6580 - name : Commit and push changes
66- if : steps.check_enabled.outputs.enabled == 'true' && steps.check_changes.outputs.changes == 'true'
81+ if : steps.check_enabled.outputs.enabled == 'true' && steps.check_loop.outputs.skip != 'true' && steps. check_changes.outputs.changes == 'true'
6782 run : |
6883 git config --local user.email "github-actions[bot]@users.noreply.github.com"
6984 git config --local user.name "github-actions[bot]"
0 commit comments