Skip to content

Commit f14916a

Browse files
committed
Fix code style workflow for fork pull requests
1 parent 0feb709 commit f14916a

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/php-cs-fixer.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ jobs:
2222
lint:
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v6
25+
- name: Checkout branch
26+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
27+
uses: actions/checkout@v6
28+
with:
29+
ref: ${{ github.head_ref || github.ref_name }}
30+
31+
- name: Checkout pull request merge ref
32+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
33+
uses: actions/checkout@v6
2634

2735
- name: Setup PHP
2836
uses: shivammathur/setup-php@v2
@@ -34,9 +42,15 @@ jobs:
3442
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
3543
3644
- name: Run PHP CS Fixer
45+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
3746
run: ./vendor/bin/php-cs-fixer fix --allow-risky=yes
3847

48+
- name: Check PHP CS Fixer
49+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
50+
run: ./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run --diff
51+
3952
- name: Commit Changes
53+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
4054
uses: stefanzweifel/git-auto-commit-action@v5
4155
with:
4256
commit_message: 🪄 Code Style Fixes

0 commit comments

Comments
 (0)