Skip to content

Commit ddc8e21

Browse files
committed
Allow running rebuild workflow on workflow dispatch
1 parent 67a6ea7 commit ddc8e21

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

.github/workflows/rebuild.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
rebuild:
1010
name: Rebuild Action
1111
runs-on: ubuntu-latest
12-
if: github.event.label.name == 'Rebuild'
12+
if: github.event.label.name == 'Rebuild' || github.event_name == 'workflow_dispatch'
1313

1414
permissions:
1515
contents: write # needed to push rebuilt commit
@@ -18,9 +18,10 @@ jobs:
1818
- name: Checkout
1919
uses: actions/checkout@v4
2020
with:
21-
ref: ${{ github.event.pull_request.head.ref }}
21+
ref: ${{ github.event.pull_request.head.ref || github.event.ref }}
2222

2323
- name: Remove label
24+
if: github.event_name == 'pull_request'
2425
env:
2526
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2627
PR_NUMBER: ${{ github.event.pull_request.number }}
@@ -30,7 +31,7 @@ jobs:
3031
3132
- name: Merge in changes from base branch
3233
env:
33-
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
34+
BASE_BRANCH: ${{ github.event.pull_request.base.ref || 'main' }}
3435
run: |
3536
git fetch origin "$BASE_BRANCH"
3637
@@ -64,8 +65,9 @@ jobs:
6465
python3 sync.py
6566
6667
- name: Check for changes and push
68+
id: push
6769
env:
68-
BRANCH: ${{ github.event.pull_request.head.ref }}
70+
BRANCH: ${{ github.event.pull_request.head.ref || github.event.ref }}
6971
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7072
PR_NUMBER: ${{ github.event.pull_request.number }}
7173
run: |
@@ -75,8 +77,16 @@ jobs:
7577
git add --all
7678
git commit -m "Rebuild"
7779
git push origin "HEAD:$BRANCH"
78-
echo "Pushed a commit to rebuild the Action." \
79-
"Please mark the PR as ready for review to trigger PR checks." |
80-
gh pr comment --body-file - --repo github/codeql-action "$PR_NUMBER"
81-
gh pr ready --undo --repo github/codeql-action "$PR_NUMBER"
80+
echo "::set-output name=changes::true"
8281
fi
82+
83+
- name: Notify about rebuild
84+
if: github.event_name == 'pull_request' && steps.push.outputs.changes == 'true'
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
PR_NUMBER: ${{ github.event.pull_request.number }}
88+
run: |
89+
echo "Pushed a commit to rebuild the Action." \
90+
"Please mark the PR as ready for review to trigger PR checks." |
91+
gh pr comment --body-file - --repo github/codeql-action "$PR_NUMBER"
92+
gh pr ready --undo --repo github/codeql-action "$PR_NUMBER"

0 commit comments

Comments
 (0)