forked from DataDog/dd-trace-java
-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (61 loc) · 2.5 KB
/
update-issues-on-release.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
62
63
64
65
66
name: Update issues on release
on:
release:
types: [released]
workflow_dispatch:
inputs:
milestone:
required: true
default: "0.0.0"
jobs:
update_issues:
runs-on: ubuntu-latest
steps:
- name: Get milestone for release
id: milestone
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const milestone_name = ("${{github.event_name}}" == "workflow_dispatch") ?
"${{github.event.inputs.milestone}}" : "${{github.event.release.name}}"
const milestones = await github.paginate(github.issues.listMilestones, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all'
})
return milestones.find( milestone => milestone.title == milestone_name ).number
- name: Get issues for milestone
id: issues
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issues = await github.paginate(github.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all',
milestone: ${{steps.milestone.outputs.result}}
})
// Pull requests are issues so filter them out
return issues.filter( issue => !issue["pull_request"] ).map( issue => issue.number )
- name: Comment and close issues
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
for (let issue_number of ${{ steps.issues.outputs.result }}) {
// This can be parallelized better by moving the await but it might trip rate limits
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: ':robot: This issue has been addressed in the latest release. See full details in the [Release Notes]( ${{ github.event.release.html_url }}).'
})
await github.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
state: 'closed'
})
}