-
Notifications
You must be signed in to change notification settings - Fork 4.9k
154 lines (154 loc) · 6.17 KB
/
moving-cards.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
# This workflow is built to manage the triage support by using GH issues.
name: '[Support] Cards movements'
on:
project_card:
types:
- created
- moved
# Remove all permissions by default
permissions: {}
jobs:
get-issue:
runs-on: ubuntu-latest
name: Get issue info
permissions:
issues: read
pull-requests: read
outputs:
assignees: ${{ steps.get-issue-step.outputs.assignees }}
author: ${{ steps.get-issue-step.outputs.author }}
type: ${{ steps.get-issue-step.outputs.type }}
draft: ${{ steps.get-issue-step.outputs.draft }}
number: ${{ steps.get-issue-step.outputs.number }}
steps:
- name: Get issue info
id: get-issue-step
run: |
issue_info=$(curl -s --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X GET -G "${{ github.event.project_card.content_url }}" )
assignees="$(echo $issue_info | jq -cr '.assignees')"
author="$(echo $issue_info | jq -r '.user.login')"
pull_request="$(echo $issue_info | jq -r '.pull_request')"
draft="$(echo $issue_info | jq -r '.draft' | sed -r "s|null|false|g")"
number="$(echo $issue_info | jq -r '.number')"
type="pull_request"
if [[ "${pull_request}" == "null" ]]; then
type="issue"
fi
echo "assignees=${assignees}" >> $GITHUB_OUTPUT
echo "author=${author}" >> $GITHUB_OUTPUT
echo "type=${type}" >> $GITHUB_OUTPUT
echo "draft=${draft}" >> $GITHUB_OUTPUT
echo "number=${number}" >> $GITHUB_OUTPUT
label-card:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
needs:
- get-issue
steps:
- name: Repo checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Load .env file
uses: xom9ikk/dotenv@v2
with:
path: .github/workflows/
# Now handling the needed labeling
- name: Triage labeling
# Only if moved into triage
if: ${{ github.event.project_card.column_id == env.TRIAGE_COLUMN_ID }}
uses: fmulero/labeler@1.1.0
with:
add-labels: triage
remove-labels: on-hold, in-progress, solved
- name: From Bitnami labeling
if: ${{ github.event.project_card.column_id == env.BITNAMI_COLUMN_ID }}
uses: fmulero/labeler@1.1.0
with:
add-labels: ${{ (needs.get-issue.outputs.author == 'bitnami-bot' && needs.get-issue.outputs.type == 'pull_request') && 'automated, auto-merge' || 'bitnami' }}
remove-labels: on-hold, in-progress, triage, solved
- name: Verify labeling
# Only if moved into bitnami column and the PR is ready for review
# Consecutive calls were fixed in fmulero/labeler@1.1.0, see https://github.com/fmulero/labeler/pull/2
if: |
github.event.project_card.column_id == env.BITNAMI_COLUMN_ID &&
needs.get-issue.outputs.type == 'pull_request' && needs.get-issue.outputs.draft == 'false'
uses: fmulero/labeler@1.1.0
with:
repo-token: ${{ secrets.BITNAMI_BOT_TOKEN }}
add-labels: verify
- name: Build Maintenance labeling
if: ${{ github.event.project_card.column_id == env.BUILD_MAINTENANCE_COLUMN_ID }}
uses: fmulero/labeler@1.1.0
with:
add-labels: review-required
remove-labels: auto-merge
- name: On hold labeling
# Only if moved into on hold
if: ${{ github.event.project_card.column_id == env.ON_HOLD_COLUMN_ID }}
uses: fmulero/labeler@1.1.0
with:
add-labels: on-hold
remove-labels: triage, in-progress, solved
- name: In progress labeling
# Only if moved into In progress
if: ${{ github.event.project_card.column_id == env.IN_PROGRESS_COLUMN_ID }}
uses: fmulero/labeler@1.1.0
with:
add-labels: in-progress
remove-labels: on-hold, triage, solved
- name: Solved labeling
# Only if moved into Solved and the issue author is not bitnami-bot
if: |
github.event.project_card.column_id == env.SOLVED_COLUMN_ID &&
(needs.get-issue.outputs.author != 'bitnami-bot')
uses: fmulero/labeler@1.1.0
with:
add-labels: solved
# Triage is not on the list to know how many issues/PRs are solved
# directly on triage
remove-labels: in-progress, on-hold
assign-assignee-if-needed:
runs-on: ubuntu-latest
permissions:
contents: read
needs:
- get-issue
# The job shouldn't run for solved cards
steps:
- name: Repo checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Load .env file
uses: xom9ikk/dotenv@v2
with:
path: .github/workflows/
- name: Assign to a person to work on it
# Assign when there is nobody assigned or the card is new.
# Cards in Build Maintenance column will remain unassigned.
if: |
github.event.project_card.column_id != env.SOLVED_COLUMN_ID && github.event.project_card.column_id != env.BUILD_MAINTENANCE_COLUMN_ID &&
(needs.get-issue.outputs.assignees == '[]' || github.event.action == 'created')
uses: pozil/auto-assign-issue@v1.11.0
with:
numOfAssignee: 1
teams: ${{ github.event.project_card.column_id == env.BITNAMI_COLUMN_ID && env.SUPPORT_TEAM_NAME || env.TRIAGE_TEAM_NAME }}
repo-token: ${{ secrets.BITNAMI_BOT_TOKEN }}
allowSelfAssign: false
- name: Reassign when moved into 'In progress' from 'Triage'
# Reassigned when moved into In progress FROM Triage
if: |
github.event.action == 'moved' && needs.get-issue.outputs.assignees != '[]' &&
github.event.project_card.column_id == env.IN_PROGRESS_COLUMN_ID &&
github.event.changes.column_id.from == env.TRIAGE_COLUMN_ID
uses: pozil/auto-assign-issue@v1.11.0
with:
numOfAssignee: 1
removePreviousAssignees: true
teams: ${{ env.SUPPORT_TEAM_NAME }}
repo-token: ${{ secrets.BITNAMI_BOT_TOKEN }}
allowSelfAssign: false