Skip to content

Commit 39cb7d8

Browse files
authored
Changelog label assist sticky removal and slash-command recheck
Use delete: true for marocchino sticky comment removal, dispatch changelog-label-recheck after /needs-changelog and /no-changelog apply labels, and listen for that event in the check workflow so merge gating updates without a new push.
1 parent b359f70 commit 39cb7d8

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

.github/workflows/changelog-label-assist.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
types: [created]
1818

1919
permissions:
20+
actions: write
2021
pull-requests: write
2122
issues: write
2223

@@ -97,9 +98,10 @@ jobs:
9798
with:
9899
header: changelog-label
99100
number: ${{ github.event.pull_request.number }}
100-
message: ''
101+
delete: true
101102

102103
- name: Apply changelog label from slash command
104+
id: slash_command
103105
if: github.event_name == 'issue_comment' && github.event.issue.pull_request
104106
env:
105107
GH_TOKEN: ${{ github.token }}
@@ -166,3 +168,28 @@ jobs:
166168
ack="Applied label \`no-changelog\`. Please add a brief note in the PR description explaining why a release note is not needed (e.g. under the changelog question in the PR template). Merge is not blocked on this — only the label is required."
167169
fi
168170
gh api "repos/${repo}/issues/${pr}/comments" -f "body=${ack}"
171+
172+
# Sticky removal must proceed even if the recheck below fails.
173+
echo "applied=true" >> "$GITHUB_OUTPUT"
174+
175+
# GITHUB_TOKEN label changes do not re-trigger pull_request workflows; rerun the PR check (best-effort).
176+
run_id=""
177+
page=1
178+
while [[ -z "${run_id}" && "${page}" -le 10 ]]; do
179+
run_id="$(gh api "repos/${repo}/actions/workflows/changelog-label-check.yml/runs?per_page=100&page=${page}&event=pull_request" \
180+
--jq ".workflow_runs[] | select(any(.pull_requests[]?; .number == ${pr})) | .id" 2>/dev/null | head -1)" || true
181+
page=$((page + 1))
182+
done
183+
if [[ -n "${run_id}" ]]; then
184+
gh run rerun "${run_id}" || echo "::warning::Failed to rerun changelog-label-check run ${run_id} for PR ${pr}"
185+
else
186+
echo "::warning::No pull_request changelog-label-check run found for PR ${pr}; merge gate may need a manual re-run."
187+
fi
188+
189+
- name: Remove sticky changelog reminder after slash command
190+
if: github.event_name == 'issue_comment' && steps.slash_command.outputs.applied == 'true'
191+
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
192+
with:
193+
header: changelog-label
194+
number: ${{ github.event.issue.number }}
195+
delete: true

.github/workflows/changelog-label-check.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ jobs:
2323
- name: Validate changelog label on PR
2424
env:
2525
GH_TOKEN: ${{ github.token }}
26+
PR_NUMBER: ${{ github.event.pull_request.number }}
2627
run: |
2728
set -euo pipefail
2829
2930
repo="${{ github.repository }}"
30-
pr="${{ github.event.pull_request.number }}"
31+
pr="${PR_NUMBER}"
32+
33+
if [[ ! "${pr}" =~ ^[0-9]+$ ]]; then
34+
echo "::error::Invalid pull request number: ${pr}"
35+
exit 1
36+
fi
3137
3238
mapfile -t labels < <(gh api "repos/${repo}/pulls/${pr}" --jq '.labels[].name')
3339

0 commit comments

Comments
 (0)