Skip to content

Fix php-cs-fixer push trigger on 3.6 (keep pull_request_target behaviour unchanged) - #150

Merged
berfinyuksel merged 1 commit into
3.6from
devops/fix-php-cs-fixer-push-ref-3.6
Jul 31, 2026
Merged

Fix php-cs-fixer push trigger on 3.6 (keep pull_request_target behaviour unchanged)#150
berfinyuksel merged 1 commit into
3.6from
devops/fix-php-cs-fixer-push-ref-3.6

Conversation

@berfinyuksel

Copy link
Copy Markdown
Contributor

Summary

Fix PHP-CS-Fixer silently discarding its own fixes on push to this maintenance branch, without changing any trigger.

-            head_ref: ${{ github.event.pull_request.head.ref }}
-            repository: ${{ github.event.pull_request.head.repo.full_name }}
+            head_ref: ${{ github.head_ref || github.ref_name }}
+            repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}

The bug

On a push event github.event.pull_request does not exist, so both inputs resolve to empty strings. The reusable workflow then falls back to ref: github.sha — a bare commit, which always lands in detached HEAD. php-cs-fixer runs and computes real fixes, but git-auto-commit-action cannot push from detached HEAD (fatal: You are not currently on a branch), so every fix is silently thrown away.

Same root cause as pimcore/data-quality-management-bundle#328; tracked in pimcore/service-operations#1071.

Why this shape, and not #328's exact change

#328 used repository: ${{ github.repository }}, which is correct for push-only workflows. This branch also has a pull_request_target trigger, so hardcoding the base repo would make every fork PR check out a branch name that doesn't exist in the base repo — trading a silent push failure for a loud fork-PR failure.

The || fallback keeps both paths correct, and matches the idiom already used elsewhere:

Event head_ref repository
push github.ref_name (a branch → not detached) base repo
PR, same-repo github.head_ref base repo
PR, from fork github.head_ref fork repo

Fork-PR behaviour is unchanged. On pull_request_target, github.head_ref is exactly github.event.pull_request.head.ref, and the || still resolves to the fork's full_name — so both inputs evaluate to the same values they do today. Only the push path changes.

Triggers are deliberately left untouched: the pull_request vs pull_request_target decision is still open in pimcore/product-management#1311, and this fix intentionally does not pre-empt it.

Verification

  • YAML parses; both pull_request_target and push triggers intact; config_file untouched.
  • Post-merge, a push run's git-auto-commit step should no longer report detached HEAD.

Related: pimcore/service-operations#1071, pimcore/data-quality-management-bundle#328, pimcore/product-management#1311

Copilot AI review requested due to automatic review settings July 31, 2026 10:46
@berfinyuksel berfinyuksel added this to the 3.6.3 milestone Jul 31, 2026
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes PHP-CS-Fixer pushes by checking out the branch rather than a detached commit.

Changes:

  • Uses push-event fallbacks for branch and repository.
  • Preserves existing pull-request and fork behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@berfinyuksel
berfinyuksel merged commit d56bc54 into 3.6 Jul 31, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants