-
Notifications
You must be signed in to change notification settings - Fork 289
61 lines (58 loc) · 2.4 KB
/
increment-milestones-on-tag.yaml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Increment milestones on tag
on:
create
jobs:
increment_milestone:
if: github.event.ref_type == 'tag' && contains(github.ref_name,'-RC') == false && github.event.master_branch == 'master'
runs-on: ubuntu-latest
steps:
- name: Get milestone title
id: milestoneTitle
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0
with:
result-encoding: string
script: |
// Our tags are of the form vX.X.X and milestones don't have the "v"
return '${{github.event.ref}}'.startsWith('v') ? '${{github.event.ref}}'.substring(1) : '${{github.event.ref}}';
- name: Get milestone for tag
id: milestone
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const milestones = await github.paginate(github.issues.listMilestones, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all'
})
const milestone = milestones.find(milestone => milestone.title == '${{steps.milestoneTitle.outputs.result}}')
if (milestone) {
return milestone.number
} else {
return null
}
- name: Close milestone
if: fromJSON(steps.milestone.outputs.result)
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
await github.issues.updateMilestone({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
milestone_number: ${{steps.milestone.outputs.result}}
})
- name: Get next minor version
if: fromJSON(steps.milestone.outputs.result)
id: semvers
uses: WyriHaximus/github-action-next-semvers@33d116a4c239252582a60a1ba8dbba63ad493ffd # 1.1.0
with:
version: ${{steps.milestoneTitle.outputs.result}}
- name: Create next milestone
if: fromJSON(steps.milestone.outputs.result)
uses: WyriHaximus/github-action-create-milestone@b86699ba7511fa3b61154ac8675d86b01938fc16 # 1.0.0
with:
title: ${{ steps.semvers.outputs.minor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}