-
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (168 loc) · 6.75 KB
/
triageops.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: TriageOps
on:
issues:
types: [ opened ]
workflow_dispatch:
inputs:
issue_number:
description: GitHub issue number to run against
required: true
workflow:
type: choice
options:
- new-thread-setup
required: true
# We only need contents:read permission since we'll be authenticate as our
# own GitHUb app here.
permissions:
contents: read
jobs:
######################## AUTOMATED ########################
new-thread-setup:
name: Setup new thread
runs-on: ubuntu-latest
if: ${{ github.event.action == 'opened' }}
steps:
- uses: actions/create-github-app-token@v1
name: "Generate GitHub app token for @recaptimedev-automation[app]"
id: app-token
with:
app-id: ${{ secrets.GH_RTDEV_APP_ID }}
private-key: ${{ secrets.GH_RTDEV_APP_KEY }}
owner: recaptime-dev
- uses: actions/checkout@v3
- name: "Check if author is on github-team:transparency-log-threads"
uses: tspascoal/get-user-teams-membership@v3
id: teamAuthCheck
with:
team: 'transparency-log-threads'
username: ${{ github.actor }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Lock issue
uses: OSDKDev/lock-issues@v1.1
with:
repo-token: ${{ steps.app-token.outputs.token }}
- name: Auto-reply and close if not part of allowlist
if: ${{ steps.teamAuthCheck.outputs.isTeamMember == 'false' }}
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const comment = `\
Hi @${context.actor}!
You are currently not yet allowlisted to create your own \
thread here. Please see the [README][readme] for more information \
on how to request access. Once you have been allowlisted, you may reopen this \
issue.
[readme]: https://github.com/recaptime-dev/transparency-log-threads/blob/main/README.md
`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
github.rest.issues.update({
issue_number: context.issue.number,
wner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
state_reason: "not_planned"
})
- name: Parse issue form
if: ${{ steps.teamAuthCheck.outputs.isTeamMember == 'true' }}
uses: stefanbuck/github-issue-parser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/form.yml
- name: Set labels based on role
if: ${{ steps.teamAuthCheck.outputs.isTeamMember == 'true' }}
uses: redhat-plumbers-in-action/advanced-issue-labeler@v2
with:
issue-form: ${{ steps.issue-parser.outputs.jsonString }}
section: role
token: ${{ steps.app-token.outputs.token }}
######################## MANUAL ACTIONS ########################
new-thread-setup-manual:
name: 'Setup new thread [manual triggered]'
runs-on: ubuntu-latest
if: ${{ github.event.inputs.workflow == 'new-thread-setup' }}
steps:
- uses: actions/create-github-app-token@v1
name: "Generate GitHub app token for @recaptimedev-automation[app]"
id: app-token
with:
app-id: ${{ secrets.GH_RTDEV_APP_ID }}
private-key: ${{ secrets.GH_RTDEV_APP_KEY }}
owner: recaptime-dev
- uses: actions/checkout@v3
- name: Fetch issue info from API
uses: actions/github-script@v7
with:
script: |
return github.rest.issues.get({
issue_number: context.payload.inputs.issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
});
github-token: ${{ steps.app-token.outputs.token }}
id: issueData
- name: "Check if author is on github-team:transparency-log-threads"
uses: tspascoal/get-user-teams-membership@v3
id: teamAuthCheck
with:
team: 'transparency-log-threads'
username: ${{ fromJson(steps.issueData.outputs.result).data.user.login }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Lock issue
if: ${{ fromJson(steps.issueData.outputs.result).locked == 'false' }}
uses: OSDKDev/lock-issues@v1.1
with:
repo-token: ${{ steps.app-token.outputs.token }}
issue-number: ${{ github.event.inputs.issue_number }}
- name: Auto-reply and close if not part of allowlist
if: ${{ steps.teamAuthCheck.outputs.isTeamMember == 'false' }}
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const { data } = await github.rest.issues.get({
issue_number: context.payload.inputs.issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const comment = `\
Hi @${data.user.login}!
You are currently not yet allowlisted to create your own \
thread here. Please see the [README][readme] for more information \
on how to request access. Once you have been allowlisted, you may reopen this \
issue.
[readme]: https://github.com/recaptime-dev/transparency-log-threads/blob/main/README.md
`
github.rest.issues.createComment({
issue_number: context.payload.inputs.issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
github.rest.issues.update({
issue_number: context.payload.inputs.issue_number,
wner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
state_reason: "not_planned"
})
- name: Parse issue form
if: ${{ steps.teamAuthCheck.outputs.isTeamMember == 'true' }}
uses: stefanbuck/github-issue-parser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/form.yml
issue-body: ${{ fromJson(steps.issueData.outputs.result).data.body }}
- name: Set labels based on role
if: ${{ steps.teamAuthCheck.outputs.isTeamMember == 'true' }}
uses: redhat-plumbers-in-action/advanced-issue-labeler@v2
with:
issue-form: ${{ steps.issue-parser.outputs.jsonString }}
section: role
token: ${{ steps.app-token.outputs.token }}