@@ -34,30 +34,41 @@ jobs:
3434
3535 # 4️⃣ Run PHPCBF (auto-fix issues)
3636 - name : Run PHPCBF
37- run : phpcbf --standard=PSR12 src/ || true
37+ run : |
38+ # Run PHPCBF but ignore exit code so workflow continues
39+ phpcbf --standard=PSR12 src/ || true
40+
41+ # Check if PHPCBF changed any files
42+ if ! git diff --quiet; then
43+ echo "PHPCBF_CHANGED=true" >> $GITHUB_ENV
44+ else
45+ echo "PHPCBF_CHANGED=false" >> $GITHUB_ENV
46+ fi
3847
3948 # 5️⃣ Commit & push fixes back to branch
4049 - name : Commit and push PHPCBF fixes
41- if : github.ref != 'refs/heads/main' # optional: skip main
50+ if : env.PHPCBF_CHANGED == 'true'
4251 env :
4352 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4453 run : |
4554 git config user.name "github-actions[bot]"
4655 git config user.email "github-actions[bot]@users.noreply.github.com"
56+
57+ # Add all PHPCBF-modified files
4758 git add .
48- # commit only if there are changes
49- if ! git diff-index --quiet HEAD; then
50- git commit -m "PHPCBF: auto-fix coding standards"
51- # determine branch for PRs or direct pushes
52- BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
53- # pull remote changes to avoid rejection
54- git fetch origin $BRANCH
55- git rebase origin/$BRANCH
56- # push fixes
57- git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD: $BRANCH
58- else
59- echo "No changes to commit, skipping push."
60- fi
59+
60+ # Commit with message
61+ git commit -m "PHPCBF: auto-fix coding standards"
62+
63+ # Determine branch to push
64+ BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
65+
66+ # Pull latest to avoid push rejection
67+ git fetch origin $BRANCH
68+ git rebase origin/ $BRANCH
69+
70+ # Push PHPCBF fixes
71+ git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH
6172
6273 # 🧪 Run PHPCS + PHPStan on multiple PHP versions
6374 php-quality :
0 commit comments