-
Notifications
You must be signed in to change notification settings - Fork 0
384 lines (323 loc) · 10.9 KB
/
Copy pathproject.yaml
File metadata and controls
384 lines (323 loc) · 10.9 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
---
name: Project
on:
workflow_call:
inputs:
PROJECT_URL:
required: true
description: What project to triage issues/pr for
type: string
TRIAGE_EVENT_ACTION:
required: false
default: "${{ github.event.action }}"
description: Event action that triggered to workflow
type: string
TRIAGE_EVENT_NAME:
required: false
default: "${{ github.event_name }}"
description: Name of event that triggered to workflow
type: string
TRIAGE_ITEM_NUMBER:
required: false
default: '0'
description: Number of the item that triggered the workflow (issue/PR)
type: string
TRIAGE_ITEM_URL:
required: false
default: "none"
description: URL of the item that triggered the workflow (issue/PR)
type: string
secrets:
WORKFLOW_TOKEN:
description: Token used to with permission to the project
required: true
jobs:
debug:
name: Debug
runs-on: ubuntu-latest
steps:
- name: Variables
run: |
echo "[Debug] github.actor=${{ github.actor }}";
echo "[Debug] github.event.action=${{ github.event.action }}";
echo "[Debug] github.event.pull_request.author_association=${{ github.event.pull_request.author_association }}";
echo "[Debug] github.event_name=${{ github.event_name }}";
echo "[Debug] github.repository=${{ github.repository }}";
echo "[Debug] github.triggering_actor=${{ github.triggering_actor }}";
echo "[Debug] inputs.TRIAGE_EVENT_ACTION=${{ inputs.TRIAGE_EVENT_ACTION }}";
echo "[Debug] inputs.TRIAGE_EVENT_NAME=${{ inputs.TRIAGE_EVENT_NAME }}";
prepare:
name: Preparation
runs-on: ubuntu-latest
outputs:
triage_item_url: ${{ steps.triage_item_url.outputs.triage_item_url }}
steps:
- name: Build Item URL
id: triage_item_url
shell: bash
run: |
if [ "${{ inputs.TRIAGE_ITEM_URL }}" == "none" ]; then
if [ "${{inputs.TRIAGE_EVENT_NAME }}" == 'pull_request' ]; then
echo "triage_item_url=https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" > $GITHUB_OUTPUT;
else
echo "triage_item_url=https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}" > $GITHUB_OUTPUT;
fi;
else
echo "triage_item_url=${{ inputs.TRIAGE_ITEM_URL }}" > $GITHUB_OUTPUT;
fi;
project-add:
name: Add
needs:
- prepare
if: ${{(
(
inputs.TRIAGE_EVENT_NAME == 'issues'
&&
(
inputs.TRIAGE_EVENT_ACTION == 'opened'
||
inputs.TRIAGE_EVENT_ACTION == 'reopened'
||
inputs.TRIAGE_EVENT_ACTION == 'labeled'
||
inputs.TRIAGE_EVENT_ACTION == 'milestoned'
||
inputs.TRIAGE_EVENT_ACTION == 'demilestoned'
||
inputs.TRIAGE_EVENT_ACTION == 'closed'
||
inputs.TRIAGE_EVENT_ACTION == 'assigned'
)
)
||
(
inputs.TRIAGE_EVENT_NAME == 'pull_request'
&&
github.event.pull_request.author_association == 'MEMBER'
&&
(
inputs.TRIAGE_EVENT_ACTION == 'opened'
||
inputs.TRIAGE_EVENT_ACTION == 'edited'
||
inputs.TRIAGE_EVENT_ACTION == 'assigned'
||
inputs.TRIAGE_EVENT_ACTION == 'reopened'
||
inputs.TRIAGE_EVENT_ACTION == 'closed'
)
)
)}}
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
with:
project-url: ${{ inputs.PROJECT_URL }}
github-token: ${{ secrets.WORKFLOW_TOKEN }}
project-remove:
name: Remove
if: ${{(
inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'transferred'
)}}
runs-on: ubuntu-latest
steps:
- name: Remove From Project
run: |
echo todo;
project-fields:
name: Field Values
if: ${{(
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION != 'transferred')
||
(inputs.TRIAGE_EVENT_NAME == 'pull_request' && github.event.pull_request.author_association == 'MEMBER' )
)}}
needs:
- prepare
- project-add
runs-on: ubuntu-latest
outputs:
project-start-date: ${{ steps.start-date.outputs.values }}
project-end-date: ${{ steps.end-date.outputs.values }}
project-status: ${{ steps.status.outputs.values }}
date-value: ${{ steps.date-value.outputs.date }}
steps:
- name: Generate Date Value
id: date-value
shell: bash
run: |
echo date=$(date '+%Y-%m-%d') > $GITHUB_OUTPUT
- name: Fetch Start Date
uses: EndBug/project-fields@v2
id: start-date
with:
operation: get
fields: Start date
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
- name: Fetch End Date
uses: EndBug/project-fields@v2
id: end-date
with:
operation: get
fields: End date
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
- name: Fetch Status
uses: EndBug/project-fields@v2
id: status
with:
operation: get
fields: Status
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
project-set-start-date:
name: Set Start Date
if: ${{(
(
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'assigned')
||
(inputs.TRIAGE_EVENT_NAME == 'pull_request' && github.event.pull_request.author_association == 'MEMBER')
)
&&
needs.project-fields.outputs.project-start-date == ''
)}}
needs:
- prepare
- project-fields
runs-on: ubuntu-latest
steps:
- name: Set Start Date
if: ${{ needs.project-fields.outputs.project-start-date == '' }}
uses: EndBug/project-fields@v2
with:
operation: set
fields: Start date
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
values: ${{ needs.project-fields.outputs.date-value }}
project-set-status:
name: Set Status
if: ${{(
needs.project-fields.outputs.project-status != 'Awaiting Feedback'
&&
needs.project-fields.outputs.project-status != 'In progress'
)}}
needs:
- prepare
- project-fields
runs-on: ubuntu-latest
steps:
- name: Set Status Accepted
if: ${{(
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'milestoned')
&&
(needs.project-fields.outputs.project-status != 'Done')
&&
(
(needs.project-fields.outputs.project-status == '')
||
(needs.project-fields.outputs.project-status == 'Planning')
)
)}}
uses: EndBug/project-fields@v2
with:
operation: set
fields: Status
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
values: 'Accepted'
- name: Set Status In Progress
if: ${{(
(
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'assigned')
||
(
inputs.TRIAGE_EVENT_NAME == 'pull_request'
&&
inputs.TRIAGE_EVENT_ACTION != 'closed'
&&
github.event.pull_request.author_association == 'MEMBER'
)
)
)}}
uses: EndBug/project-fields@v2
with:
operation: set
fields: Status
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
values: 'In progress'
- name: Set Status done
if: inputs.TRIAGE_EVENT_ACTION == 'closed'
uses: EndBug/project-fields@v2
with:
operation: set
fields: Status
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
values: 'Done'
- name: Clear Status
if: ${{(
(
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'reopened')
||
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'demilestoned')
)
&&
needs.project_fields.project-status != 'Ready to Commence'
)}}
uses: EndBug/project-fields@v2
with:
operation: clear
fields: Status
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
project-set-end-date:
name: Set End Date
if: ${{(
needs.project-fields.outputs.project-start-date != ''
&&
(
inputs.TRIAGE_EVENT_ACTION == 'closed'
||
inputs.TRIAGE_EVENT_ACTION == 'reopened'
)
)}}
needs:
- prepare
- project-fields
runs-on: ubuntu-latest
steps:
- name: Set End date
if: ${{(
inputs.TRIAGE_EVENT_ACTION == 'closed'
&&
needs.project-fields.outputs.project-end-date == ''
)}}
uses: EndBug/project-fields@v2
with:
operation: set
fields: End date
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
values: ${{ needs.project-fields.outputs.date-value }}
- name: Clear End Date
if: ${{(
inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'reopened'
)}}
uses: EndBug/project-fields@v2
with:
operation: clear
fields: End date
github_token: ${{ secrets.WORKFLOW_TOKEN }}
project_url: ${{ inputs.PROJECT_URL }}
resource_url: ${{ needs.prepare.outputs.triage_item_url }}