-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a GitHub Actions based alternative to the milestone bot that we run. The actions setup will - When a PR is opened or reopened, and has no milestone associated, it will assign the `next` milestone - When a PR is milestoned or demilestoned, it will add a status to the PR like the current bot does it. This should allow us to require a milestone to be set before merging, without having to host the bot anymore.
- Loading branch information
1 parent
3a033ae
commit ca44b3f
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Check PR milestone | ||
|
||
on: | ||
pull_request_target: | ||
types: [milestoned, demilestoned, opened, reopened] | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check_milestone: | ||
if: ${{ github.event.issue.pull_request || github.event.pull_request }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Check for milestone on PR" | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
let milestone = context.payload.pull_request.milestone; | ||
if(context.payload.action === 'opened' || context.payload.action === 'reopened') { | ||
if(milestone !== null) { | ||
core.notice(`Milestone is ${milestone.title}`); | ||
} else { | ||
const milestones = await github.rest.issues.listMilestones({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
state: "open" | ||
}); | ||
for (const default_milestone of milestones.data) { | ||
if (default_milestone.title === "next") { | ||
core.notice(`No milestone set, setting default milestone: ${default_milestone.title}`); | ||
await github.rest.issues.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
milestone: default_milestone.number | ||
}); | ||
return; | ||
} | ||
} | ||
core.warning("Could not find default milestone named 'next'"); | ||
} | ||
} | ||
else { | ||
if(milestone !== null) { | ||
core.notice(`Milestone is ${milestone.title}`); | ||
} else { | ||
core.setFailed("No milestone: Please add a version milestone"); | ||
} | ||
} |