-
Notifications
You must be signed in to change notification settings - Fork 68
299 lines (282 loc) · 14.3 KB
/
move_card.yml
File metadata and controls
299 lines (282 loc) · 14.3 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
name: "Move the Issue after workload and urgency is evaluated"
# This file is part of t8code.
# t8code is a C library to manage a collection (a forest) of multiple
# connected adaptive space-trees of general element types in parallel.
#
# Copyright (C) 2025 the developers
#
# t8code is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# t8code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with t8code; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
on:
issues:
types: [labeled, assigned, unassigned, unlabeled, opened]
pull_request:
types: [opened, reopened, ready_for_review, review_requested, review_request_removed, closed]
jobs:
evaluate_issues:
if: ${{ github.event_name == 'issues' }}
runs-on: ubuntu-latest
outputs:
WORKLOAD_SET: ${{ steps.check_workload.outputs.WORKLOAD_SET || 'false' }}
PRIORITY_SET: ${{ steps.check_urgency.outputs.PRIORITY_SET || 'false' }}
WORKLOAD: ${{ steps.check_workload.outputs.WORKLOAD || 'false' }}
PRIORITY: ${{ steps.check_urgency.outputs.PRIORITY || 'false' }}
CREATION_DATE: ${{ steps.get_creation_date.outputs.CREATION_DATE || 'unset' }}
steps:
- name: "Extract the issues date of creation"
id: get_creation_date
run: |
echo "Extract the date of creation:"
github_date_string="${{ github.event.issue.created_at }}"
CREATION_DATE="${github_date_string:0:10}"
echo "$CREATION_DATE"
echo "CREATION_DATE=$CREATION_DATE" >> $GITHUB_OUTPUT
- name: "Check if workload is set"
id: check_workload
# Check if the issue has a workload label
if: |
contains(join(github.event.issue.labels.*.name, ','), 'workload:high') ||
contains(join(github.event.issue.labels.*.name, ','), 'workload:medium') ||
contains(join(github.event.issue.labels.*.name, ','), 'workload:low')
run: |
# Set WORKLOAD_SET to true
WORKLOAD_SET=true
echo "WORKLOAD_SET=$WORKLOAD_SET" >> $GITHUB_OUTPUT
# extract the workload value. Suppresses error messages from jq. If the label can not be found, an empty string is added.
labels=$(echo '${{ toJSON(github.event.issue.labels) }}' | jq -r '.[]?.name' 2>/dev/null || echo "")
workload=$(echo "$labels" | grep -oE 'workload:(high|medium|low)' | cut -d: -f2)
echo "WORKLOAD=$workload"
WORKLOAD=$workload
echo "WORKLOAD=$WORKLOAD" >> $GITHUB_OUTPUT
echo "WORKLOAD=$WORKLOAD"
echo "WORKLOAD_SET=$WORKLOAD_SET"
echo "${{ github.event.action }}"
- name: "Check if workload has not been set"
id: check_workload_not_set
if: |
!contains(join(github.event.issue.labels.*.name, ','), 'workload:high') &&
!contains(join(github.event.issue.labels.*.name, ','), 'workload:medium') &&
!contains(join(github.event.issue.labels.*.name, ','), 'workload:low')
run: |
# Set WORKLOAD_SET to false
WORKLOAD_SET=false
echo "WORKLOAD_SET=$WORKLOAD_SET" >> $GITHUB_OUTPUT
echo "WORKLOAD_SET=$WORKLOAD_SET"
- name: "Check if priority is set"
id: check_urgency
# Check if the issue has a priority label
if: |
contains(join(github.event.issue.labels.*.name, ','), 'priority:high') ||
contains(join(github.event.issue.labels.*.name, ','), 'priority:medium') ||
contains(join(github.event.issue.labels.*.name, ','), 'priority:low')
run: |
# Set PRIORITY_SET to true
PRIORITY_SET=true
echo "PRIORITY_SET=$PRIORITY_SET" >> $GITHUB_OUTPUT
# extract the priority value. Suppresses error messages from jq. If the label can not be found, an empty string is added.
labels=$(echo '${{ toJSON(github.event.issue.labels) }}' | jq -r '.[]?.name' 2>/dev/null || echo "")
priority=$(echo "$labels" | grep -oE 'priority:(high|medium|low)' | cut -d: -f2)
echo "PRIORITY=$priority"
PRIORITY=$priority
echo "PRIORITY=$PRIORITY" >> $GITHUB_OUTPUT
echo "PRIORITY=$PRIORITY"
echo "PRIORITY_SET=$PRIORITY_SET"
echo "${{ github.event.action }}"
- name: "Check if priority has not been set"
id: check_urgency_not_set
if: |
!contains(join(github.event.issue.labels.*.name, ','), 'priority:high') &&
!contains(join(github.event.issue.labels.*.name, ','), 'priority:medium') &&
!contains(join(github.event.issue.labels.*.name, ','), 'priority:low')
run: |
# Set PRIORITY_SET to false
PRIORITY_SET=false
echo "PRIORITY_SET=$PRIORITY_SET" >> $GITHUB_OUTPUT
echo "PRIORITY_SET=$PRIORITY_SET"
evaluate_pr:
runs-on: ubuntu-latest
# Don't run in parallel on the same PR. Otherwise multiple issues might be created for the same PR.
concurrency:
group: pr-move-card-${{ github.event.pull_request.id }}
outputs:
NUMBER_IS_SET: ${{ steps.get_pr_issue_link.outputs.NUMBER_IS_SET }}
CLEAN_ISSUE_NUMBER: ${{ steps.get_pr_issue_link.outputs.CLEAN_ISSUE_NUMBER }}
REPO_NODE_ID: ${{ steps.get_pr_issue_link.outputs.REPO_NODE_ID }}
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: "Get link between PR and Issue"
id: get_pr_issue_link
run: |
# Extract the repository node ID from the pull request event
REPO_NODE_ID=$(jq -r '.repository.node_id' < $GITHUB_EVENT_PATH)
echo "REPO_NODE_ID=$REPO_NODE_ID"
echo "REPO_NODE_ID=$REPO_NODE_ID" >> $GITHUB_OUTPUT
# Extract the issue number from the pull request body
CLEAN_ISSUE_NUMBER=$(jq -r '.pull_request.body // ""' < $GITHUB_EVENT_PATH | grep -oEi '\b([cC]lose|[cC]loses|[cC]losed|[fF]ix|[fF]ixes|[fF]ixed|[rR]esolve|[rR]esolves|[rR]esolved) #[0-9]+' | grep -oE '[0-9]+' | paste -sd ',' -)
# Set the issue number to an empty string if no issue number is found
CLEAN_ISSUE_NUMBER=${CLEAN_ISSUE_NUMBER:-""}
echo "CLEAN_ISSUE_NUMBER=$CLEAN_ISSUE_NUMBER"
# If no issue number is found, set NUMBER_IS_SET to false
if [ -z "$CLEAN_ISSUE_NUMBER" ]; then
echo "No issue number found in the pull request body."
NUMBER_IS_SET=false
echo "NUMBER_IS_SET=$NUMBER_IS_SET" >> $GITHUB_OUTPUT
echo "NUMBER_IS_SET=$NUMBER_IS_SET"
exit 0
fi
echo "CLEAN_ISSUE_NUMBER=$CLEAN_ISSUE_NUMBER" >> $GITHUB_OUTPUT
NUMBER_IS_SET=true
echo "NUMBER_IS_SET=true" >> $GITHUB_OUTPUT
# Debug output!
echo "NUMBER_IS_SET=$NUMBER_IS_SET"
echo "${{ github.event.action }}"
# Add the issue's date of creation to the project board card.
# Triggered only if the issue was newly opened or the label 'manual_trigger_date_event' has been added.
add_creation_date:
needs: [evaluate_issues]
if: ${{ github.event.action == 'opened' || ( github.event.action == 'labeled' && contains(join(github.event.issue.labels.*.name, ','), 'manual_trigger_date_event') ) }}
uses: ./.github/workflows/add_date_created.yml
with:
ISSUE_NODE_ID: ${{ github.event.issue.node_id }}
CREATION_DATE: ${{ needs.evaluate_issues.outputs.CREATION_DATE }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# Move the issue card to ToDo if the workload and priority are set
move_card_to_ToDo:
needs: [evaluate_issues]
if: ${{ github.event.action == 'labeled' && needs.evaluate_issues.outputs.WORKLOAD_SET == 'true' && needs.evaluate_issues.outputs.PRIORITY_SET == 'true' }}
uses: ./.github/workflows/issue_event_moves_card.yml
with:
ISSUE_NODE_ID: ${{ github.event.issue.node_id }}
CURRENT_COLUMN_NAME: 'In-Box'
COLUMN_NAME: 'ToDo'
PRIORITY: ${{ needs.evaluate_issues.outputs.PRIORITY }}
WORKLOAD: ${{ needs.evaluate_issues.outputs.WORKLOAD }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# Move the Issue card to In Progress if the workload and priority are set and the issue is assigned
move_card_to_InProgress:
needs: [evaluate_issues]
if: ${{ needs.evaluate_issues.outputs.WORKLOAD_SET == 'true' && needs.evaluate_issues.outputs.PRIORITY_SET == 'true' && github.event.action == 'assigned' }}
uses: ./.github/workflows/issue_event_moves_card.yml
with:
ISSUE_NODE_ID: ${{ github.event.issue.node_id }}
CURRENT_COLUMN_NAME: 'ToDo'
COLUMN_NAME: 'In Progress'
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# Move the Issue card back to ToDo if the workload and priority are set and the issue is unassigned
move_card_back_to_ToDo:
needs: [evaluate_issues]
if: ${{ needs.evaluate_issues.outputs.WORKLOAD_SET == 'true' && needs.evaluate_issues.outputs.PRIORITY_SET == 'true' && github.event.action == 'unassigned' }}
uses: ./.github/workflows/issue_event_moves_card.yml
with:
ISSUE_NODE_ID: ${{ github.event.issue.node_id }}
CURRENT_COLUMN_NAME: 'In Progress'
COLUMN_NAME: 'ToDo'
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# Move the Issue card back to In-Box if the workload and priority are unset
move_card_back_to_In-Box:
needs: [evaluate_issues]
if: ${{ github.event.action == 'unlabeled' && (needs.evaluate_issues.outputs.WORKLOAD_SET == 'false' || needs.evaluate_issues.outputs.PRIORITY_SET == 'false') }}
uses: ./.github/workflows/issue_event_moves_card.yml
with:
ISSUE_NODE_ID: ${{ github.event.issue.node_id }}
CURRENT_COLUMN_NAME: 'ToDo'
COLUMN_NAME: 'In-Box'
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# For a PR event, move the card to Needs Review if the PR is opened, ready for review, or reopened
move_card_to_Needs_Review:
needs: [evaluate_pr]
if: ${{ needs.evaluate_pr.outputs.NUMBER_IS_SET == 'true' && (github.event.action == 'opened' || github.event.action == 'ready_for_review' || github.event.action == 'reopened') }}
uses: ./.github/workflows/pr_event_moves_card.yml
with:
ISSUE_NUMBER: ${{ needs.evaluate_pr.outputs.CLEAN_ISSUE_NUMBER }}
CURRENT_COLUMN_NAME: 'In Progress'
COLUMN_NAME: 'Needs Review'
REPO_NODE_ID: ${{ needs.evaluate_pr.outputs.REPO_NODE_ID }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# For a PR event move the card to In Review if a review is requested
move_card_to_In_Review:
needs: [evaluate_pr]
if: ${{ needs.evaluate_pr.outputs.NUMBER_IS_SET == 'true' && github.event.action == 'review_requested' }}
uses: ./.github/workflows/pr_event_moves_card.yml
with:
ISSUE_NUMBER: ${{ needs.evaluate_pr.outputs.CLEAN_ISSUE_NUMBER }}
CURRENT_COLUMN_NAME: 'Needs Review'
COLUMN_NAME: 'In Review'
REPO_NODE_ID: ${{ needs.evaluate_pr.outputs.REPO_NODE_ID }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# For a PR event move the card back to Needs Review if a review is removed
move_card_back_to_Needs_Review:
needs: [evaluate_pr]
if: ${{ needs.evaluate_pr.outputs.NUMBER_IS_SET == 'true' && github.event.action == 'review_request_removed' }}
uses: ./.github/workflows/pr_event_moves_card.yml
with:
ISSUE_NUMBER: ${{ needs.evaluate_pr.outputs.CLEAN_ISSUE_NUMBER }}
CURRENT_COLUMN_NAME: 'In Review'
COLUMN_NAME: 'Needs Review'
REPO_NODE_ID: ${{ needs.evaluate_pr.outputs.REPO_NODE_ID }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# For a PR event move the card back to In Progress if the PR is closed and not merged
move_card_back_to_In_Progress:
needs: [evaluate_pr]
if: ${{ needs.evaluate_pr.outputs.NUMBER_IS_SET == 'true' && github.event.action == 'closed' && github.event.pull_request.merged == false }}
uses: ./.github/workflows/pr_event_moves_card.yml
with:
ISSUE_NUMBER: ${{ needs.evaluate_pr.outputs.CLEAN_ISSUE_NUMBER }}
CURRENT_COLUMN_NAME: 'Needs Review'
COLUMN_NAME: 'In Progress'
REPO_NODE_ID: ${{ needs.evaluate_pr.outputs.REPO_NODE_ID }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# For a PR event where no issue is linked, open a new issue and add "Closes #ISSUE_NUMBER" to the PR body
open_issue_for_quick_pr:
needs: [evaluate_pr]
if: ${{ github.event_name == 'pull_request' && needs.evaluate_pr.outputs.NUMBER_IS_SET == 'false' }}
uses: ./.github/workflows/quick_pr.yml
with:
DEFAULT_PROJECT: "t8code's Issue Landing page"
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# After the issue has been created by open_issue_for_quick_pr, move the card to Needs Review
move_quick_pr_issue_to_Needs_Review:
needs: [open_issue_for_quick_pr, evaluate_pr]
uses: ./.github/workflows/pr_event_moves_card.yml
if: ${{ !github.event.pull_request.draft }}
with:
ISSUE_NUMBER: ${{ needs.open_issue_for_quick_pr.outputs.ISSUE_NUMBER }}
CURRENT_COLUMN_NAME: 'IGNORE'
COLUMN_NAME: 'Needs Review'
REPO_NODE_ID: ${{ needs.evaluate_pr.outputs.REPO_NODE_ID }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}
# After the issue has been created by open_issue_for_quick_pr, move the card to In Progress. The triggering PR is a draft PR,
# therefore we don't want to move the card to Needs Review.
move_quick_draft_pr_issue_to_In_Progress:
needs: [open_issue_for_quick_pr, evaluate_pr]
uses: ./.github/workflows/pr_event_moves_card.yml
if: ${{ github.event.pull_request.draft }}
with:
ISSUE_NUMBER: ${{ needs.open_issue_for_quick_pr.outputs.ISSUE_NUMBER }}
CURRENT_COLUMN_NAME: 'IGNORE'
COLUMN_NAME: 'In Progress'
REPO_NODE_ID: ${{ needs.evaluate_pr.outputs.REPO_NODE_ID }}
secrets:
PAT: ${{ secrets.T8DDY_PROJECTS }}