Skip to content

Rebuild scoped Rector after a pull request is merged#730

Merged
TomasVotruba merged 1 commit into
mainfrom
dispatch-build-scoped-rector-on-merge
Jul 14, 2026
Merged

Rebuild scoped Rector after a pull request is merged#730
TomasVotruba merged 1 commit into
mainfrom
dispatch-build-scoped-rector-on-merge

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Merging a rule pull request here changes rectorphp/rector only once something else lands in rector-src main and retriggers its build. This dispatches that build directly instead.

New .github/workflows/dispatch_build_scoped_rector.yaml:

on:
    pull_request:
        types:
            - closed

jobs:
    dispatch_build_scoped_rector:
        # only for merged pull requests in this repository, not forks
        if: github.event.pull_request.merged == true && github.repository == 'rectorphp/rector-phpunit'

        runs-on: ubuntu-latest

        steps:
            -
                name: "Trigger build_scoped_rector.yaml in rectorphp/rector-src"
                env:
                    GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
                run: gh workflow run build_scoped_rector.yaml --repo rectorphp/rector-src --ref main

pull_request: closed fires on every close, so the merged == true check is what limits it to merges. Closed-without-merge dispatches nothing. Reuses the ACCESS_TOKEN secret already used by rector.yaml.

Merge rectorphp/rector-src#8188 first

build_scoped_rector.yaml has no workflow_dispatch trigger today, so gh workflow run returns HTTP 422 until rectorphp/rector-src#8188 lands. This pull request is inert but red on its own.

Two things to verify before merging

ACCESS_TOKEN needs actions: write on rectorphp/rector-src. rector.yaml only uses it to push to this repository, so cross-repository scope is unconfirmed — worth one manual gh workflow run against rector-src with that token.

The dispatch fires at merge time, but the build resolves rector-phpunit dev-main through Packagist, which can lag a merge by a few minutes. A dispatched build may rebuild against the previous main. A Packagist update hook on this repository is the fix; not included here.

Dispatches build_scoped_rector.yaml in rectorphp/rector-src, so
rectorphp/rector picks up merged changes without waiting for the next
commit to rector-src main.

Requires rectorphp/rector-src#8188, which adds the workflow_dispatch
trigger the run relies on.
@TomasVotruba TomasVotruba merged commit 059615d into main Jul 14, 2026
8 checks passed
@TomasVotruba TomasVotruba deleted the dispatch-build-scoped-rector-on-merge branch July 14, 2026 15:45
@samsonasik

Copy link
Copy Markdown
Member

If latest commit in rector-src is a release tag, rebuild should not be allowed as it will fail due to retagging

@TomasVotruba

Copy link
Copy Markdown
Member Author

Good point!

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.

2 participants