Skip to content

Commit

Permalink
add github action to assign milestone automatically (nvaccess#16779)
Browse files Browse the repository at this point in the history
NV Access has a server side script to automatically assign milestones to closed issues and PRs. This script has been malfunctioning for some time meaning we are not tracking which release issues are closed in.

Description of development approach
Used copilot to generate a github action to assign milestones.
  • Loading branch information
seanbudd authored Aug 5, 2024
1 parent d6ef98e commit a8d39d0
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/assign-milestone-on-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Assign Milestone on Close

env:
MILESTONE_ID: ${{ vars.MILESTONE_ID }}

on:
issues:
types: [closed]
pull_request:
types: [closed]

jobs:
assign-milestone:
runs-on: ubuntu-latest
steps:
- name: Check if milestone is set
id: check-milestone
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueOrPr = context.payload.issue || context.payload.pull_request;
if (!issueOrPr.milestone) {
core.setOutput('milestoneNotSet', 'true');
} else {
core.setOutput('milestoneNotSet', 'false');
}
- name: Assign default milestone
if: steps.check-milestone.outputs.milestoneNotSet == 'true'
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueOrPrNumber = (context.payload.issue || context.payload.pull_request).number;
const repository = context.repo;
await github.rest.issues.update({
...repository,
issue_number: issueOrPrNumber,
milestone: process.env.MILESTONE_ID
});

0 comments on commit a8d39d0

Please sign in to comment.