Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions .github/workflows/php-quality.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: PHP Auto-Fix & Quality Check
name: PHP Quality

on:
pull_request:
branches:
- master
push:
branches:
- '**'
pull_request:
types: [opened, synchronize, reopened]
- master

jobs:
# 🔧 Auto-fix coding standards (only once, PHP 8.1)
Expand Down Expand Up @@ -34,30 +35,41 @@ jobs:

# 4️⃣ Run PHPCBF (auto-fix issues)
- name: Run PHPCBF
run: phpcbf --standard=PSR12 src/ || true
run: |
# Run PHPCBF but ignore exit code so workflow continues
phpcbf --standard=PSR12 src/ || true

# Check if PHPCBF changed any files
if ! git diff --quiet; then
echo "PHPCBF_CHANGED=true" >> $GITHUB_ENV
else
echo "PHPCBF_CHANGED=false" >> $GITHUB_ENV
fi

# 5️⃣ Commit & push fixes back to branch
- name: Commit and push PHPCBF fixes
if: github.ref != 'refs/heads/main' # optional: skip main
if: env.PHPCBF_CHANGED == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Add all PHPCBF-modified files
git add .
# commit only if there are changes
if ! git diff-index --quiet HEAD; then
git commit -m "PHPCBF: auto-fix coding standards"
# determine branch for PRs or direct pushes
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
# pull remote changes to avoid rejection
git fetch origin $BRANCH
git rebase origin/$BRANCH
# push fixes
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH
else
echo "No changes to commit, skipping push."
fi

# Commit with message
git commit -m "PHPCBF: auto-fix coding standards"

# Determine branch to push
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"

# Pull latest to avoid push rejection
git fetch origin $BRANCH
git rebase origin/$BRANCH

# Push PHPCBF fixes
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH

# 🧪 Run PHPCS + PHPStan on multiple PHP versions
php-quality:
Expand Down