Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions .github/workflows/fix-milestone-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ on:
types: [closed]
branches: [main, net*.0, inflight/*, release/*]

# When a stable release tag is pushed (e.g. 10.0.80), audit the entire tag
# cohort and fix any milestone drift, closing issues fixed by PRs that
# shipped in this tag. The pattern matches MAJOR.MINOR.PATCH where MAJOR is
# pinned to a currently-supported major (10 or 11) to bound the blast radius —
# a stray tag like 1.2.3 or 7.0.0 must NOT fire the bulk -Apply path. Because
# GitHub Actions filter patterns must match the whole ref, preview/rc tags
# like 11.0.0-preview.5.26304.4 or 10.0.0-rc.1.25424.2 are deliberately
# excluded (the trailing -preview/-rc suffix breaks the full-ref match).
# NOTE: bump this glob (and the bash guard below) when a new major ships.
Comment thread
kubaflo marked this conversation as resolved.
Resolved
#
# NOTE: a tag pushed using the default GITHUB_TOKEN does NOT trigger this
# workflow — GitHub suppresses workflow runs for events raised by the default
# token to avoid loops. Release tags must therefore be pushed by a human or by
# automation using a PAT / GitHub App token, otherwise this trigger will
# silently never fire (today SR tags are pushed by a maintainer, so it does).
push:
tags:
- '1[01].[0-9]+.[0-9]+'

workflow_dispatch:
inputs:
pr_number:
Expand Down Expand Up @@ -38,8 +57,9 @@ permissions:

jobs:
manage-milestones:
# For PR merges: only run when actually merged (not just closed)
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
# For PR merges: only run when actually merged (not just closed).
# Tag pushes and manual dispatches always run.
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout with full history
Expand All @@ -57,11 +77,23 @@ jobs:
INPUT_CREATE_ISSUE: ${{ inputs.create_issue }}
INPUT_CLOSE_FIXED_ISSUES: ${{ inputs.close_fixed_issues }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PUSH_TAG: ${{ github.ref_name }}
EVENT_NAME: ${{ github.event_name }}
run: |
ARGS=()

if [ "$EVENT_NAME" = "pull_request_target" ]; then
if [ "$EVENT_NAME" = "push" ]; then
# Release tag pushed: audit the whole tag cohort, fix milestone
# drift, and close issues fixed by PRs that shipped in this tag.
# Defense-in-depth: the `on.push.tags` filter already restricts to
# MAJOR.MINOR.PATCH, but re-validate here so an unexpected ref can
# never be passed through to the script's tag-mode.
if [[ ! "$PUSH_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::push tag '$PUSH_TAG' is not a stable release tag (expected MAJOR.MINOR.PATCH)"
exit 1
fi
ARGS+=('-Tag' "$PUSH_TAG" '-Apply' '-CloseFixedIssues')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Blast radius — auto -Apply -CloseFixedIssues on every matching tag push (3/3 reviewers)

All three reviewers independently flagged that this fires bulk, irreversible issue closures + milestone moves on any push of a MAJOR.MINOR.PATCH tag, with no dry-run gate. Tag-mode -CloseFixedIssues closes every linked open issue across the whole PrevTag..ReleaseTag cohort. This is your deliberate posture (validated live against 10.0.80), so flagging for visibility — not as a blocker. Two mitigations worth considering:

  • a tag-protection ruleset on [0-9]+.[0-9]+.[0-9]+ so only trusted release automation/maintainers can create matching tags;
  • optionally gating the job on github.ref_protected == true.

I deliberately did not add the ref_protected gate here: if matching tags aren't actually marked protected in the repo ruleset, that gate would silently disable the trigger entirely — your call, since you know the tag-ruleset config. As-is, a stray tag like 1.2.3 on the wrong commit would fire the full apply path.

elif [ "$EVENT_NAME" = "pull_request_target" ]; then
# Auto-trigger: set milestone on the merged PR
ARGS+=('-PrNumber' "$INPUT_PR_NUMBER" '-Apply')
# GitHub only auto-closes "fixes #N" issues for PRs merged to the
Expand Down
Loading