1+ name : " On Comment"
2+
3+ on :
4+ issue_comment :
5+ types : [created]
6+
7+ permissions :
8+ contents : write
9+ issues : write
10+ pull-requests : write
11+
12+ jobs :
13+ # This job always runs to prevent GHA from marking the run as failed when
14+ # all other jobs are skipped.
15+ noop :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - run : echo "No-op"
19+
20+ parse_comment :
21+ runs-on : ubuntu-latest
22+ if : |
23+ github.event.comment.author_association == 'OWNER' ||
24+ github.event.comment.author_association == 'MEMBER' ||
25+ github.event.comment.author_association == 'COLLABORATOR'
26+ outputs :
27+ command : ${{ steps.parse.outputs.command }}
28+ issue_number : ${{ steps.parse.outputs.issue_number }}
29+ pr_number : ${{ steps.parse.outputs.pr_number }}
30+ backports : ${{ steps.parse.outputs.backports }}
31+ steps :
32+ - name : Parse comment
33+ id : parse
34+ env :
35+ COMMENT_BODY : ${{ github.event.comment.body }}
36+ IS_PR : " ${{ github.event.issue.pull_request != null }}"
37+ EVENT_NUMBER : " ${{ github.event.issue.number }}"
38+ HAS_RELEASE_LABEL : " ${{ contains(github.event.issue.labels.*.name, 'type: release') }}"
39+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
40+ run : |
41+ if [ "$IS_PR" = "false" ] && [ "$HAS_RELEASE_LABEL" = "true" ]; then
42+ issue_number=$EVENT_NUMBER
43+ if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/create-rc([[:space:]]|$)'; then
44+ echo "command=create-rc" >> "$GITHUB_OUTPUT"
45+ echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
46+ elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/prepare([[:space:]]|$)'; then
47+ echo "command=prepare" >> "$GITHUB_OUTPUT"
48+ echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
49+ elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/process-backports([[:space:]]|$)'; then
50+ echo "command=process-backports" >> "$GITHUB_OUTPUT"
51+ echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
52+ elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/add-backports([[:space:]]|$)'; then
53+ args=$(echo "$COMMENT_BODY" | grep -E '^[[:space:]]*/add-backports([[:space:]]|$)' | sed -E 's/^[[:space:]]*\/add-backports[[:space:]]*//')
54+ args=$(echo "$args" | sed -e 's/^[[:space:],]*//' -e 's/[[:space:],]*$//')
55+ csv=$(echo "$args" | sed -E 's/[[:space:],]+/ /g' | tr ' ' ',')
56+ if [ -n "$csv" ]; then
57+ echo "command=add-backports" >> "$GITHUB_OUTPUT"
58+ echo "backports=$csv" >> "$GITHUB_OUTPUT"
59+ echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
60+ else
61+ echo "command=none" >> "$GITHUB_OUTPUT"
62+ echo "Error: No PRs specified for add-backports." >&2
63+ gh api \
64+ --method POST \
65+ -H "Accept: application/vnd.github+json" \
66+ -H "X-GitHub-Api-Version: 2022-11-28" \
67+ /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
68+ -f "content=-1"
69+ fi
70+ elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/promote([[:space:]]|$)'; then
71+ echo "command=promote" >> "$GITHUB_OUTPUT"
72+ echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
73+ else
74+ echo "command=none" >> "$GITHUB_OUTPUT"
75+ fi
76+ elif [ "$IS_PR" = "true" ]; then
77+ pr_number=$EVENT_NUMBER
78+ if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/backport([[:space:]]|$)'; then
79+ echo "command=pr-backport" >> "$GITHUB_OUTPUT"
80+ echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
81+ else
82+ echo "command=none" >> "$GITHUB_OUTPUT"
83+ fi
84+ else
85+ echo "command=none" >> "$GITHUB_OUTPUT"
86+ fi
87+
88+ call_create_rc :
89+ needs : parse_comment
90+ if : needs.parse_comment.outputs.command == 'create-rc'
91+ uses : ./.github/workflows/release_create_rc.yaml
92+ with :
93+ issue : ${{ needs.parse_comment.outputs.issue_number }}
94+ comment_id : " ${{ github.event.comment.id }}"
95+ secrets : inherit
96+
97+ call_prepare :
98+ needs : parse_comment
99+ if : needs.parse_comment.outputs.command == 'prepare'
100+ uses : ./.github/workflows/release_prepare.yaml
101+ with :
102+ issue : ${{ needs.parse_comment.outputs.issue_number }}
103+ secrets : inherit
104+
105+ call_add_backports :
106+ needs : parse_comment
107+ if : |
108+ needs.parse_comment.outputs.command == 'add-backports' ||
109+ needs.parse_comment.outputs.command == 'pr-backport'
110+ uses : ./.github/workflows/release_add_backports.yaml
111+ with :
112+ prs : ${{ needs.parse_comment.outputs.command == 'pr-backport' && needs.parse_comment.outputs.pr_number || needs.parse_comment.outputs.backports }}
113+ issue : ${{ needs.parse_comment.outputs.issue_number }}
114+ secrets : inherit
115+
116+ call_process_backports_after_add :
117+ needs : [parse_comment, call_add_backports]
118+ if : needs.parse_comment.outputs.command == 'add-backports'
119+ uses : ./.github/workflows/release_process_backports.yaml
120+ with :
121+ issue : ${{ needs.parse_comment.outputs.issue_number }}
122+ comment_id : " ${{ github.event.comment.id }}"
123+ secrets : inherit
124+
125+ call_process_backports_only :
126+ needs : parse_comment
127+ if : needs.parse_comment.outputs.command == 'process-backports'
128+ uses : ./.github/workflows/release_process_backports.yaml
129+ with :
130+ issue : ${{ needs.parse_comment.outputs.issue_number }}
131+ comment_id : " ${{ github.event.comment.id }}"
132+ secrets : inherit
133+
134+ call_promote :
135+ needs : parse_comment
136+ if : needs.parse_comment.outputs.command == 'promote'
137+ uses : ./.github/workflows/release_promote_rc.yaml
138+ with :
139+ issue : ${{ needs.parse_comment.outputs.issue_number }}
140+ secrets : inherit
0 commit comments