Skip to content

Commit 5dc1803

Browse files
committed
Allow dispatching Build Scoped Rector manually
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.
1 parent a4f37d9 commit 5dc1803

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

.github/workflows/build_scoped_rector.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- main
99
tags:
1010
- '*'
11+
# allows rector-* package repositories to rebuild after their pull request is merged
12+
workflow_dispatch: null
1113

1214
env:
1315
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
@@ -108,6 +110,8 @@ jobs:
108110
-
109111
name: "Get Git log"
110112
id: git-log
113+
# "before"/"after" exist only in the push event payload
114+
if: github.event_name == 'push'
111115
run: |
112116
echo "log<<EOF" >> $GITHUB_OUTPUT
113117
echo "$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='https://github.com/rectorphp/rector-src/commit/%H %s')" >> $GITHUB_OUTPUT
@@ -122,7 +126,8 @@ jobs:
122126
INPUT_LOG: ${{ steps.git-log.outputs.log }}
123127
run: |
124128
git add --all
125-
git commit -m "Updated Rector to commit ${{ github.event.after }}" -m "$INPUT_LOG"
129+
# a dispatched build can produce no change at all, e.g. after a test-only pull request
130+
git diff --staged --quiet || git commit -m "Updated Rector to commit ${{ github.sha }}" -m "$INPUT_LOG"
126131
git push --quiet origin main
127132
128133
# 8.B publish it to remote repository with tag

0 commit comments

Comments
 (0)