Skip to content

Allow dispatching Build Scoped Rector manually#8188

Merged
TomasVotruba merged 1 commit into
mainfrom
add-workflow-dispatch-to-build-scoped-rector
Jul 14, 2026
Merged

Allow dispatching Build Scoped Rector manually#8188
TomasVotruba merged 1 commit into
mainfrom
add-workflow-dispatch-to-build-scoped-rector

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds a workflow_dispatch trigger to build_scoped_rector.yaml, so rector-* package repositories can rebuild rectorphp/rector right after merging a pull request of their own. Companion pull request in rector-phpunit does the dispatching.

 on:
     push:
         branches:
             - main
         tags:
             - '*'
+    # allows rector-* package repositories to rebuild after their pull request is merged
+    workflow_dispatch: null

The rest of the change is what makes a dispatched run behave.

github.event.before and github.event.after only exist in the push event payload, so they are empty on a dispatched run. The git log step is limited to push events:

                 name: "Get Git log"
                 id: git-log
+                # "before"/"after" exist only in the push event payload
+                if: github.event_name == 'push'

And the commit message uses github.sha, which is identical to github.event.after on push, so push builds keep their current message verbatim:

-                    git commit -m "Updated Rector to commit ${{ github.event.after }}" -m "$INPUT_LOG"
+                    git diff --staged --quiet || git commit -m "Updated Rector to commit ${{ github.sha }}" -m "$INPUT_LOG"

The git diff --staged --quiet || guard covers a dispatched build that produces no change at all, e.g. after a test-only pull request in a package repository. Without it, git commit fails with nothing to commit and the build goes red on every such merge.

Note on ordering

A dispatch fires the moment a package pull request merges, but the build runs composer install against that package's dev-main, which Packagist can serve with a few minutes of lag. A dispatched build may therefore rebuild against the previous main. Not addressed here — a Packagist update hook on the package repositories is the proper fix, and this trigger is still useful without it.

Adds a workflow_dispatch trigger, so rector-* package repositories can
rebuild rectorphp/rector after merging a pull request of their own.

The push event payload fields "before" and "after" are empty on a
dispatched run, so the git log step is limited to push events and the
commit message uses github.sha, which is identical to github.event.after
on push. A dispatched build can also produce no change at all, so the
commit is skipped when nothing is staged.
@TomasVotruba TomasVotruba merged commit ef3c5cc into main Jul 14, 2026
65 checks passed
@TomasVotruba TomasVotruba deleted the add-workflow-dispatch-to-build-scoped-rector branch July 14, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant