Skip to content

Commit 1fa8447

Browse files
committed
Don't loop and don't run lint on forks
1 parent f6aeb3f commit 1fa8447

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.github/workflows/auto-format.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -63,7 +78,7 @@ jobs:
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]"

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Lint
22

33
on:
44
push:
5+
branches: [master, main]
56
pull_request:
67
branches: [master, main]
78

0 commit comments

Comments
 (0)