Skip to content

Commit 34505f8

Browse files
authored
Merge pull request #4 from nofusscomputing/3-preperation
2 parents ace6aa9 + 4dade1b commit 34505f8

File tree

1 file changed

+100
-29
lines changed

1 file changed

+100
-29
lines changed

.github/workflows/project.yaml

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@ on:
1010
required: true
1111
description: What project to triage issues/pr for
1212
type: string
13+
TRIAGE_EVENT_ACTION:
14+
required: false
15+
default: "${{ github.event.action }}"
16+
description: Event action that triggered to workflow
17+
type: string
18+
TRIAGE_EVENT_NAME:
19+
required: false
20+
default: "${{ github.event_name }}"
21+
description: Name of event that triggered to workflow
22+
type: string
23+
TRIAGE_ITEM_NUMBER:
24+
required: false
25+
default: 0
26+
description: Number of the item that triggered the workflow (issue/PR)
27+
type: number
28+
TRIAGE_ITEM_URL:
29+
required: false
30+
default: "none"
31+
description: URL of the item that triggered the workflow (issue/PR)
32+
type: string
1333
secrets:
1434
WORKFLOW_TOKEN:
1535
description: Token used to with permission to the project
@@ -32,43 +52,80 @@ jobs:
3252
echo "[Debug] github.event.pull_request.author_association=${{ github.event.pull_request.author_association }}";
3353
echo "[Debug] github.triggering_actor=${{ github.triggering_actor }}";
3454
55+
echo "[Debug] inputs.TRIAGE_EVENT_ACTION=${{ inputs.TRIAGE_EVENT_ACTION }}";
56+
echo "[Debug] inputs.TRIAGE_EVENT_NAME=${{ inputs.TRIAGE_EVENT_NAME }}";
57+
58+
59+
prepare:
60+
name: Preparation
61+
runs-on: ubuntu-latest
62+
outputs:
63+
triage_item_url: ${{ steps.triage_item_url.outputs.triage_item_url }}
64+
steps:
65+
66+
67+
- name: Build Item URL
68+
id: triage_item_url
69+
shell: bash
70+
run: |
71+
72+
if [ "${{ inputs.TRIAGE_ITEM_URL }}" == "none" ]; then
73+
74+
if [ "${{inputs.TRIAGE_EVENT_NAME }}" == 'pull_request' ]; then
75+
76+
echo "triage_item_url=https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" > $GITHUB_OUTPUT;
77+
78+
else
79+
80+
echo "triage_item_url=https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}" > $GITHUB_OUTPUT;
81+
82+
fi;
83+
84+
else
85+
86+
echo "triage_item_url=${{ inputs.TRIAGE_ITEM_URL }}" > $GITHUB_OUTPUT;
87+
88+
fi;
89+
3590
3691
project-add:
3792
name: Add
93+
needs:
94+
- prepare
3895
if: ${{(
3996
(
40-
github.event_name == 'issues'
97+
inputs.TRIAGE_EVENT_NAME == 'issues'
4198
&&
4299
(
43-
github.event.action == 'opened'
100+
inputs.TRIAGE_EVENT_ACTION == 'opened'
44101
||
45-
github.event.action == 'reopened'
102+
inputs.TRIAGE_EVENT_ACTION == 'reopened'
46103
||
47-
github.event.action == 'labeled'
104+
inputs.TRIAGE_EVENT_ACTION == 'labeled'
48105
||
49-
github.event.action == 'milestoned'
106+
inputs.TRIAGE_EVENT_ACTION == 'milestoned'
50107
||
51-
github.event.action == 'demilestoned'
108+
inputs.TRIAGE_EVENT_ACTION == 'demilestoned'
52109
||
53-
github.event.action == 'closed'
110+
inputs.TRIAGE_EVENT_ACTION == 'closed'
54111
||
55-
github.event.action == 'assigned'
112+
inputs.TRIAGE_EVENT_ACTION == 'assigned'
56113
)
57114
)
58115
||
59116
(
60-
github.event_name == 'pull_request'
117+
inputs.TRIAGE_EVENT_NAME == 'pull_request'
61118
&&
62119
(
63-
github.event.action == 'opened'
120+
inputs.TRIAGE_EVENT_ACTION == 'opened'
64121
||
65-
github.event.action == 'edited'
122+
inputs.TRIAGE_EVENT_ACTION == 'edited'
66123
||
67-
github.event.action == 'assigned'
124+
inputs.TRIAGE_EVENT_ACTION == 'assigned'
68125
||
69-
github.event.action == 'reopened'
126+
inputs.TRIAGE_EVENT_ACTION == 'reopened'
70127
||
71-
github.event.action == 'closed'
128+
inputs.TRIAGE_EVENT_ACTION == 'closed'
72129
)
73130
)
74131
)}}
@@ -85,7 +142,7 @@ jobs:
85142
project-remove:
86143
name: Remove
87144
if: ${{(
88-
github.event_name == 'issues' && github.event.action == 'transferred'
145+
inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'transferred'
89146
)}}
90147
runs-on: ubuntu-latest
91148
steps:
@@ -99,11 +156,12 @@ jobs:
99156
project-fields:
100157
name: Field Values
101158
if: ${{(
102-
(github.event_name == 'issues' && github.event.action != 'transferred')
159+
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION != 'transferred')
103160
||
104-
(github.event_name == 'pull_request')
161+
(inputs.TRIAGE_EVENT_NAME == 'pull_request')
105162
)}}
106163
needs:
164+
- prepare
107165
- project-add
108166
runs-on: ubuntu-latest
109167
outputs:
@@ -128,6 +186,7 @@ jobs:
128186
fields: Start date
129187
github_token: ${{ secrets.WORKFLOW_TOKEN }}
130188
project_url: ${{ inputs.PROJECT_URL }}
189+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
131190

132191

133192
- name: Fetch End Date
@@ -138,6 +197,7 @@ jobs:
138197
fields: End date
139198
github_token: ${{ secrets.WORKFLOW_TOKEN }}
140199
project_url: ${{ inputs.PROJECT_URL }}
200+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
141201

142202

143203
- name: Fetch Status
@@ -148,21 +208,23 @@ jobs:
148208
fields: Status
149209
github_token: ${{ secrets.WORKFLOW_TOKEN }}
150210
project_url: ${{ inputs.PROJECT_URL }}
211+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
151212

152213

153214

154215
project-set-start-date:
155216
name: Set Start Date
156217
if: ${{(
157218
(
158-
(github.event_name == 'issues' && github.event.action == 'assigned')
219+
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'assigned')
159220
||
160-
github.event_name == 'pull_request'
221+
inputs.TRIAGE_EVENT_NAME == 'pull_request'
161222
)
162223
&&
163224
needs.project-fields.outputs.project-start-date == ''
164225
)}}
165226
needs:
227+
- prepare
166228
- project-fields
167229
runs-on: ubuntu-latest
168230
steps:
@@ -175,6 +237,7 @@ jobs:
175237
fields: Start date
176238
github_token: ${{ secrets.WORKFLOW_TOKEN }}
177239
project_url: ${{ inputs.PROJECT_URL }}
240+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
178241
values: ${{ needs.project-fields.outputs.date-value }}
179242

180243

@@ -187,54 +250,58 @@ jobs:
187250
needs.project-fields.outputs.project-status != 'In progress'
188251
)}}
189252
needs:
253+
- prepare
190254
- project-fields
191255
runs-on: ubuntu-latest
192256
steps:
193257

194258

195259
- name: Set Status Planning
196-
if: ${{ github.event_name == 'issues' && github.event.action == 'milestoned' }}
260+
if: ${{ inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'milestoned' }}
197261
uses: EndBug/project-fields@v2
198262
with:
199263
operation: set
200264
fields: Status
201265
github_token: ${{ secrets.WORKFLOW_TOKEN }}
202266
project_url: ${{ inputs.PROJECT_URL }}
267+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
203268
values: 'Planning'
204269

205270

206271
- name: Set Status In Progress
207272
if: ${{(
208-
(github.event_name == 'issues' && github.event.action == 'assigned')
273+
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'assigned')
209274
||
210-
github.event_name == 'pull_request' && github.event.action != 'closed'
275+
inputs.TRIAGE_EVENT_NAME == 'pull_request' && inputs.TRIAGE_EVENT_ACTION != 'closed'
211276
)}}
212277
uses: EndBug/project-fields@v2
213278
with:
214279
operation: set
215280
fields: Status
216281
github_token: ${{ secrets.WORKFLOW_TOKEN }}
217282
project_url: ${{ inputs.PROJECT_URL }}
283+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
218284
values: 'In progress'
219285

220286

221287
- name: Set Status done
222-
if: ${{ github.event.action == 'closed' }}
288+
if: ${{ inputs.TRIAGE_EVENT_ACTION == 'closed' }}
223289
uses: EndBug/project-fields@v2
224290
with:
225291
operation: set
226292
fields: Status
227293
github_token: ${{ secrets.WORKFLOW_TOKEN }}
228294
project_url: ${{ inputs.PROJECT_URL }}
295+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
229296
values: 'Done'
230297

231298

232299
- name: Clear Status
233300
if: ${{(
234301
(
235-
(github.event_name == 'issues' && github.event.action == 'reopened')
302+
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'reopened')
236303
||
237-
(github.event_name == 'issues' && github.event.action == 'demilestoned')
304+
(inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'demilestoned')
238305
)
239306
&&
240307
needs.project_fields.project-status != 'Ready to Commence'
@@ -245,6 +312,7 @@ jobs:
245312
fields: Status
246313
github_token: ${{ secrets.WORKFLOW_TOKEN }}
247314
project_url: ${{ inputs.PROJECT_URL }}
315+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
248316

249317

250318

@@ -254,20 +322,21 @@ jobs:
254322
needs.project-fields.outputs.project-start-date != ''
255323
&&
256324
(
257-
github.event.action == 'closed'
325+
inputs.TRIAGE_EVENT_ACTION == 'closed'
258326
||
259-
github.event.action == 'reopened'
327+
inputs.TRIAGE_EVENT_ACTION == 'reopened'
260328
)
261329
)}}
262330
needs:
331+
- prepare
263332
- project-fields
264333
runs-on: ubuntu-latest
265334
steps:
266335

267336

268337
- name: Set End date
269338
if: ${{(
270-
github.event.action == 'closed'
339+
inputs.TRIAGE_EVENT_ACTION == 'closed'
271340
&&
272341
needs.project-fields.outputs.project-end-date == ''
273342
)}}
@@ -277,16 +346,18 @@ jobs:
277346
fields: End date
278347
github_token: ${{ secrets.WORKFLOW_TOKEN }}
279348
project_url: ${{ inputs.PROJECT_URL }}
349+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}
280350
values: ${{ needs.project-fields.outputs.date-value }}
281351

282352

283353
- name: Clear End Date
284354
if: ${{(
285-
github.event_name == 'issues' && github.event.action == 'reopened'
355+
inputs.TRIAGE_EVENT_NAME == 'issues' && inputs.TRIAGE_EVENT_ACTION == 'reopened'
286356
)}}
287357
uses: EndBug/project-fields@v2
288358
with:
289359
operation: clear
290360
fields: End date
291361
github_token: ${{ secrets.WORKFLOW_TOKEN }}
292362
project_url: ${{ inputs.PROJECT_URL }}
363+
resource_url: ${{ needs.prepare.outputs.triage_item_url }}

0 commit comments

Comments
 (0)