Skip to content

Commit f3fa8da

Browse files
authored
build(release): support triggering release workflows via comments (#3889)
Allows maintainers to trigger release workflows (prepare, create-rc, process-backports) by commenting on the release tracking issue. This automates the release process further and reduces the need to manually trigger workflows from the GitHub Actions UI. - Created a central `on_issue_comment.yaml` workflow to parse comments. - Updated `release_prepare.yaml`, `release_create_rc.yaml`, and `release_process_backports.yaml` to be reusable workflows. - Updated the release tracking issue template to document the new comment commands.
1 parent 8396c28 commit f3fa8da

5 files changed

Lines changed: 112 additions & 8 deletions

File tree

.github/ISSUE_TEMPLATE/release_tracking_template.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ labels: ['type: release']
1818
To request a backport:
1919
1. Add a new checklist item under the `## Backports` section.
2020
2. The format must be: `- [ ] #<PR_NUMBER>` (e.g., `- [ ] #1234`).
21-
3. Trigger the [Process Backports Workflow](https://github.com/bazel-contrib/rules_python/actions/workflows/process_backports.yml).
21+
3. Trigger the [Process Backports Workflow][process_backports].
2222
</details>
2323

2424
---
@@ -36,8 +36,22 @@ The checklist items use metadata suffix: `| key=value key2=value2`.
3636
<details>
3737
<summary><b>Available Commands</b></summary>
3838

39-
Maintainers can trigger automation by running manual workflows:
40-
- [Process Backports Workflow](https://github.com/bazel-contrib/rules_python/actions/workflows/process_backports.yml)
41-
- [Generate RC Tag Workflow](https://github.com/bazel-contrib/rules_python/actions/workflows/generate_rc.yml)
42-
- [Promote RC to Final Release Workflow](https://github.com/bazel-contrib/rules_python/actions/workflows/promote_rc.yml)
39+
Maintainers can trigger automation by:
40+
- Running manual workflows:
41+
- [Process Backports Workflow][process_backports]
42+
- [Create RC Workflow][create_rc]
43+
- [Promote RC to Final Release Workflow][promote_rc]
44+
- Commenting on this issue (requires the issue to have the `type: release`
45+
label):
46+
- `/prepare` at the beginning of a line to trigger the Release Prepare
47+
workflow.
48+
- `/create-rc` at the beginning of a line to trigger the Create RC
49+
workflow.
50+
- `/process-backports` at the beginning of a line to trigger the Process
51+
Backports workflow.
52+
4353
</details>
54+
55+
[process_backports]: https://github.com/bazel-contrib/rules_python/actions/workflows/release_process_backports.yaml
56+
[create_rc]: https://github.com/bazel-contrib/rules_python/actions/workflows/release_create_rc.yaml
57+
[promote_rc]: https://github.com/bazel-contrib/rules_python/actions/workflows/release_promote_rc.yaml
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: "On Issue Comment"
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
contents: read
9+
issues: read
10+
11+
jobs:
12+
# This job always runs to prevent GHA from marking the run as failed when
13+
# all other jobs are skipped.
14+
noop:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- run: echo "No-op"
18+
19+
parse_comment:
20+
runs-on: ubuntu-latest
21+
if: |
22+
github.event.issue.pull_request == null &&
23+
contains(github.event.issue.labels.*.name, 'type: release') &&
24+
(github.event.comment.author_association == 'OWNER' ||
25+
github.event.comment.author_association == 'MEMBER' ||
26+
github.event.comment.author_association == 'COLLABORATOR')
27+
outputs:
28+
command: ${{ steps.parse.outputs.command }}
29+
issue_number: ${{ github.event.issue.number }}
30+
steps:
31+
- name: Parse comment
32+
id: parse
33+
env:
34+
COMMENT_BODY: ${{ github.event.comment.body }}
35+
run: |
36+
if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/create-rc([[:space:]]|$)'; then
37+
echo "command=create-rc" >> "$GITHUB_OUTPUT"
38+
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/prepare([[:space:]]|$)'; then
39+
echo "command=prepare" >> "$GITHUB_OUTPUT"
40+
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/process-backports([[:space:]]|$)'; then
41+
echo "command=process-backports" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "command=none" >> "$GITHUB_OUTPUT"
44+
fi
45+
46+
call_create_rc:
47+
needs: parse_comment
48+
if: needs.parse_comment.outputs.command == 'create-rc'
49+
uses: ./.github/workflows/release_create_rc.yaml
50+
with:
51+
issue: ${{ needs.parse_comment.outputs.issue_number }}
52+
secrets: inherit
53+
54+
call_prepare:
55+
needs: parse_comment
56+
if: needs.parse_comment.outputs.command == 'prepare'
57+
uses: ./.github/workflows/release_prepare.yaml
58+
with:
59+
issue: ${{ needs.parse_comment.outputs.issue_number }}
60+
secrets: inherit
61+
62+
call_process_backports:
63+
needs: parse_comment
64+
if: needs.parse_comment.outputs.command == 'process-backports'
65+
uses: ./.github/workflows/release_process_backports.yaml
66+
with:
67+
issue: ${{ needs.parse_comment.outputs.issue_number }}
68+
secrets: inherit

.github/workflows/release_create_rc.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
description: 'The Release Tracking Issue Number (e.g., 142)'
88
required: true
99
type: string
10+
workflow_call:
11+
inputs:
12+
issue:
13+
description: 'The Release Tracking Issue Number (e.g., 142)'
14+
required: true
15+
type: string
1016

1117
permissions:
1218
contents: write

.github/workflows/release_prepare.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ name: "Release: Prepare"
22

33
on:
44
workflow_dispatch:
5-
# Allow manual triggering to prepare the release immediately
5+
inputs:
6+
issue:
7+
description: 'The Release Tracking Issue Number (e.g., 142)'
8+
required: false
9+
type: string
10+
workflow_call:
11+
inputs:
12+
issue:
13+
description: 'The Release Tracking Issue Number (e.g., 142)'
14+
required: false
15+
type: string
616

717
permissions:
818
contents: write
@@ -30,7 +40,7 @@ jobs:
3040
3141
- name: Run Release Preparation Pipeline
3242
run: |
33-
# Manual trigger: run full preparation
34-
bazel run //tools/private/release -- prepare --no-dry-run
43+
bazel run //tools/private/release -- \
44+
prepare ${{ inputs.issue && format('--issue={0}', inputs.issue) || '' }} --no-dry-run
3545
env:
3646
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release_process_backports.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
description: 'The Release Tracking Issue Number (e.g., 142)'
88
required: true
99
type: string
10+
workflow_call:
11+
inputs:
12+
issue:
13+
description: 'The Release Tracking Issue Number (e.g., 142)'
14+
required: true
15+
type: string
1016

1117
permissions:
1218
contents: write

0 commit comments

Comments
 (0)