-
Notifications
You must be signed in to change notification settings - Fork 30
44 lines (38 loc) · 1.82 KB
/
set-milestone-on-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
on:
pull_request:
branches: [master]
types: [closed]
jobs:
set-milestone:
if: github.event.pull_request.merged == true
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Compute milestone
run: |
echo "MILESTONE_NUMBER=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec | cut -d- -f1)" >> $GITHUB_ENV
- name: Set milestone
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// Get milestone
const milestone = process.env.MILESTONE_NUMBER
console.log(`Using milestone with name ${milestone}`)
// Check if milestone exists
const issuesGetMilestonesParams = context.repo
// Search if milestone is already defined
const response = await github.issues.listMilestones(issuesGetMilestonesParams)
let githubMilestone = response.data.find(milestoneResponse => milestoneResponse.title === milestone)
// Create if doesn't exist
if (!githubMilestone) {
const issuesCreateMilestoneParams = { owner: context.repo.owner, repo:context.repo.repo, title: milestone }
const createMilestoneResponse = await github.issues.createMilestone(issuesCreateMilestoneParams)
githubMilestone = createMilestoneResponse.data
}
// Grab the milestone number
const milestoneNumber = githubMilestone.number
// Sets the milestone from the number
const issuesUpdateParams = { owner: context.repo.owner, repo: context.repo.repo, milestone: milestoneNumber, issue_number: context.issue.number }
await github.issues.update(issuesUpdateParams)