-
Notifications
You must be signed in to change notification settings - Fork 52
Add milestone automation for merged PRs #356
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,88 @@ | ||||||||||||||||||||||||||||||||||||||||||
| name: Milestone Automation | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||
| pull_request_target: | ||||||||||||||||||||||||||||||||||||||||||
| types: | ||||||||||||||||||||||||||||||||||||||||||
| - closed | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Disable permissions for all available scopes by default. | ||||||||||||||||||||||||||||||||||||||||||
| # Any needed permissions should be configured at the job level. | ||||||||||||||||||||||||||||||||||||||||||
| permissions: {} | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||
| # Assigns merged PRs to the appropriate milestone | ||||||||||||||||||||||||||||||||||||||||||
| assign-milestone: | ||||||||||||||||||||||||||||||||||||||||||
| name: Assign milestone to merged PR | ||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-24.04 | ||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||||||||||||||
| issues: write | ||||||||||||||||||||||||||||||||||||||||||
| # Only run on merged PRs | ||||||||||||||||||||||||||||||||||||||||||
| if: github.event.pull_request.merged == true | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||
| - name: Assign or update milestone | ||||||||||||||||||||||||||||||||||||||||||
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||||||||||||||||||||
| const pr = context.payload.pull_request; | ||||||||||||||||||||||||||||||||||||||||||
| const prNumber = pr.number; | ||||||||||||||||||||||||||||||||||||||||||
| const currentMilestone = pr.milestone; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // Fetch all open milestones | ||||||||||||||||||||||||||||||||||||||||||
| const { data: milestones } = await github.rest.issues.listMilestones({ | ||||||||||||||||||||||||||||||||||||||||||
| owner: context.repo.owner, | ||||||||||||||||||||||||||||||||||||||||||
| repo: context.repo.repo, | ||||||||||||||||||||||||||||||||||||||||||
| state: 'open', | ||||||||||||||||||||||||||||||||||||||||||
| sort: 'due_on', | ||||||||||||||||||||||||||||||||||||||||||
| direction: 'asc' | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+32
to
+39
|
||||||||||||||||||||||||||||||||||||||||||
| // Fetch all open milestones | |
| const { data: milestones } = await github.rest.issues.listMilestones({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| sort: 'due_on', | |
| direction: 'asc' | |
| }); | |
| // Fetch all open milestones (handle pagination) | |
| const milestones = await github.paginate( | |
| github.rest.issues.listMilestones, | |
| { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| sort: 'due_on', | |
| direction: 'asc', | |
| per_page: 100 | |
| } | |
| ); |
Copilot
AI
Mar 26, 2026
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.
The workflow’s “closed milestone” branch only adds a comment and does not move the PR to the earliest open milestone. This conflicts with the PR description/expected behavior (“Updates to earliest open milestone + adds comment”) and the sample comment text (which says it was moved). Update this branch to call the Issues update API to set milestone: targetMilestone.number before/alongside creating the notification comment, and align the comment text accordingly.
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.
This job only calls Issues APIs (
issues.listMilestones,issues.update,issues.createComment). Per GitHub’s fine-grainedGITHUB_TOKENpermissions,issues: writeis sufficient for updating a PR milestone and creating an issue comment on a PR, sopull-requests: writeappears unnecessary. Dropping it would reduce the workflow’s privilege surface.