Repository navigation
[29.x backport] ci: validate PR milestones using branch status issue #7535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vvoland
merged 1 commit into
docker:29.x
from
thaJeztah:29.x_backport_update_milestone_ci
Nov 19, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,91 @@ | ||
| name: validate-milestone | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, milestoned, demilestoned, edited] | ||
| types: [opened, reopened, edited, synchronize, milestoned, demilestoned] | ||
|
|
||
| jobs: | ||
| validate-milestone: | ||
| if: ${{ github.repository == 'docker/cli' && github.event.pull_request.state == 'open' }} | ||
| runs-on: ubuntu-26.04 | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Validate milestone matches VERSION | ||
| - name: Validate milestone matches next version | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | ||
| env: | ||
| MILESTONE: ${{ github.event.pull_request.milestone.title }} | ||
| # Pinned "[Branch status]" issue with a "json docker-versions" block | ||
| # mapping each branch to its next and last version. | ||
| BRANCH_STATUS_ISSUE: 7526 | ||
| with: | ||
| script: | | ||
| const files = await github.paginate(github.rest.pulls.listFiles, { | ||
| const issueNumber = Number(process.env.BRANCH_STATUS_ISSUE); | ||
| const source = `issue #${issueNumber}`; | ||
| const baseBranch = context.payload.pull_request.base.ref; | ||
| core.info(`Base branch: ${baseBranch}`); | ||
|
|
||
| const {data: issue} = await github.rest.issues.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.payload.pull_request.number, | ||
| issue_number: issueNumber, | ||
| }); | ||
| core.info(`Modified files: ${files.map(f => f.filename).join(', ')}`); | ||
|
|
||
| const touchesVersion = files.some(f => f.filename === 'VERSION'); | ||
| core.info(`Touches VERSION: ${touchesVersion}`); | ||
|
|
||
| // Use the PR's version when it bumps the file, base branch otherwise. | ||
| // It's fine to trust the author in this case, it's not meant to be | ||
| // a security gate, just a helpful check for maintainers. | ||
| const ref = touchesVersion | ||
| ? context.payload.pull_request.head.sha | ||
| : context.payload.pull_request.base.ref; | ||
| const lines = (issue.body ?? '').split('\n').map(line => line.trimEnd()); | ||
| const start = lines.indexOf('```json docker-versions') + 1; | ||
| const end = lines.indexOf('```', start); | ||
| if (start === 0 || end === -1) { | ||
| core.setFailed(`Could not find a 'json docker-versions' block in ${source}`); | ||
| return; | ||
| } | ||
|
|
||
| core.info(`Base ref: ${ref}`); | ||
| // For example: {"master": {"next": "29.10.0", "last": "29.9.1"}} | ||
| let versions; | ||
| try { | ||
| versions = JSON.parse(lines.slice(start, end).join('\n')); | ||
| } catch (err) { | ||
| core.setFailed(`Invalid 'json docker-versions' block in ${source}: ${err.message}`); | ||
| return; | ||
| } | ||
| core.info(`Versions: ${JSON.stringify(versions)}`); | ||
|
|
||
| const resp = await github.rest.repos.getContent({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| path: 'VERSION', | ||
| ref, | ||
| }); | ||
| const expected = Buffer.from(resp.data.content, resp.data.encoding).toString('utf8').trim(); | ||
| const expected = versions?.[baseBranch]?.next; | ||
| if (!expected) { | ||
| core.setFailed(`Could not find the next version for branch '${baseBranch}' in ${source}`); | ||
| return; | ||
| } | ||
| const milestone = process.env.MILESTONE; | ||
|
|
||
| if (!milestone) { | ||
| core.setFailed(`PR must have a milestone set (expected: ${expected})`); | ||
| return; | ||
| } | ||
| if (milestone !== expected) { | ||
| core.setFailed(`Milestone '${milestone}' does not match VERSION '${expected}'`); | ||
| const guidance = | ||
| 'This check prevents the PR from being merged accidentally before it is appropriate ' + | ||
| 'for its milestone. If the milestone is intentional, no action is needed.'; | ||
| await core.summary | ||
| .addHeading('This PR is intentionally blocked from merging for now') | ||
| .addTable([ | ||
| [ | ||
| {data: 'Milestone', header: true}, | ||
| {data: 'Expected next version', header: true}, | ||
| ], | ||
| [milestone, expected], | ||
| ]) | ||
| .addRaw(`The expected version for the '${baseBranch}' branch comes from ${source}.`) | ||
| .addEOL() | ||
| .addRaw(guidance) | ||
| .write(); | ||
| core.setFailed( | ||
| `This PR cannot be merged yet because milestone '${milestone}' does not match ` + | ||
| `the next version '${expected}'. ${guidance}` | ||
| ); | ||
| return; | ||
| } | ||
| core.info(`Milestone: ${milestone} ✓`); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[medium/security] Milestone validation data sourced from mutable GitHub issue instead of immutable git content
This PR replaces reading the
VERSIONfile from git (viarepos.getContent, pinned to a specific commit SHA) with reading the body of issue #7526. That issue is mutable: any maintainer with issue-edit rights can alter the expected version mapping without leaving a commit-level audit trail.Impact: The old approach tied the expected milestone to an immutable point in git history. The new approach means that whoever can edit issue #7526 controls what the CI considers the "correct" milestone for every branch. This could cause PRs to pass or fail milestone validation unexpectedly and silently.
Mitigating factors:
docker/clican edit issues, so the attack surface is limited to trusted collaborators.github.repository == 'docker/cli'guard prevents the workflow from running on forks.Recommendation: Document this trust assumption explicitly in a comment near
BRANCH_STATUS_ISSUE. For example:This makes the design decision clear to future readers and reduces surprise if the issue is ever edited unintentionally.