-
Notifications
You must be signed in to change notification settings - Fork 893
187 lines (180 loc) · 7.53 KB
/
issue-handling.yaml
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
name: Process issue workflows
"on":
issues:
types: [opened, closed, labeled]
issue_comment:
types: [created, edited]
jobs:
add-to-project:
name: Add issue to projects
# issue_comment is triggered when commenting on both issues and
# pull requests. To avoid adding pull requests to the bug board,
# filter out pull requests
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Add to bugs board
uses: actions/add-to-project@v0.5.0
with:
project-url: https://github.com/orgs/timescale/projects/55
github-token: ${{ secrets.ORG_AUTOMATION_TOKEN }}
labeled: bug, needs-triage, flaky-test
label-operator: OR
- name: Add to CAggs board
uses: actions/add-to-project@v0.5.0
with:
project-url: https://github.com/orgs/timescale/projects/128
github-token: ${{ secrets.ORG_AUTOMATION_TOKEN }}
labeled: continuous_aggregate
notify-sec:
name: Notify security channel
runs-on: ubuntu-latest
if: >-
github.event_name == 'issues' &&
github.event.action != 'closed' &&
( contains(github.event.issue.labels.*.name, 'segfault') ||
contains(github.event.issue.labels.*.name, 'security') )
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
steps:
- name: Post to Security Channel
uses: slackapi/slack-github-action@v1.25.0
with:
channel-id: '${{ secrets.SLACK_CHANNEL_SECURITY }}'
payload: |
{
"text": "Issue #${{github.event.issue.number}} (${{github.event.issue.title}})> needs attention",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Issue <${{github.event.issue.url}}|#${{github.event.issue.number}} ${{github.event.issue.title}}> needs attention"
}
}
]
}
close-issue:
name: Issue is closed
runs-on: ubuntu-latest
if: github.event_name == 'issues' && github.event.action == 'closed' && contains(github.event.issues.issue.labels.*.name, 'bug')
steps:
- uses: leonsteinhaeuser/project-beta-automations@v2.0.0
with:
gh_token: ${{ secrets.ORG_AUTOMATION_TOKEN }}
organization: timescale
project_id: 55
resource_node_id: ${{ github.event.issue.node_id }}
status_value: 'Done'
- name: Remove waiting-for-author label
uses: andymckay/labeler@3a4296e9dcdf9576b0456050db78cfd34853f260
with:
remove-labels: 'waiting-for-author, no-activity'
repo-token: ${{ secrets.ORG_AUTOMATION_TOKEN }}
waiting-for-author:
name: Waiting for Author
runs-on: ubuntu-latest
if: github.event_name == 'issues' && github.event.action == 'labeled'
&& github.event.label.name == 'waiting-for-author'
steps:
- uses: leonsteinhaeuser/project-beta-automations@v2.0.0
with:
gh_token: ${{ secrets.ORG_AUTOMATION_TOKEN }}
organization: timescale
project_id: 55
resource_node_id: ${{ github.event.issue.node_id }}
status_value: 'Waiting for Author'
waiting-for-engineering:
name: Waiting for Engineering
runs-on: ubuntu-latest
if: github.event_name == 'issue_comment' && !github.event.issue.pull_request
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install jq
- name: Get board column of issue
id: extract_board_column
continue-on-error: true
run: |
# The following GraphQL query requests all issues from a project. It uses the repository
# to locate the issue and get the reference to the project. Then, a filter is applied
# (number: $project) to get the reference to the desired project (i.e., the bug board).
# Now, all issues from this project are requested. The reason for fetching all issues is
# because the current implementation of the GitHub GraphQL API for projects does not
# support server-side filters for issues and we can not restrict the query to our issue.
# Therefore, we fetch all issues and apply a filter on the client side in the next step.
gh api graphql --paginate -F issue=$ISSUE -F project=$PROJECT -F owner=$OWNER -F repo=$REPO -f query='
query board_column($issue: Int!, $project: Int!, $owner: String!, $repo: String!, $endCursor: String) {
repository(owner: $owner, name: $repo) {
issue(number: $issue) {
projectV2(number: $project) {
items(first: 100, after: $endCursor) {
nodes {
fieldValueByName(name: "Status") {
... on ProjectV2ItemFieldSingleSelectValue {
name
}
}
content {
... on Issue {
id
title
number
repository {
name
owner {
login
}
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
}
' > api_result
# Get board column for issue
board_column=$(jq -r ".data.repository.issue.projectV2.items.nodes[] |
select (.content.number == $ISSUE and .content.repository.name == \"$REPO\" and .content.repository.owner.login == \"$OWNER\") |
.fieldValueByName.name" api_result)
echo "Issue is in column: $board_column"
echo "issue_board_column=$board_column" >> "$GITHUB_OUTPUT"
env:
OWNER: timescale
REPO: ${{ github.event.repository.name }}
PROJECT: 55
ISSUE: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }}
- name: Check if organization member
uses: tspascoal/get-user-teams-membership@v2
id: checkUserMember
with:
username: ${{ github.actor }}
organization: timescale
team: 'database-eng'
GITHUB_TOKEN: ${{ secrets.ORG_AUTOMATION_TOKEN }}
- name: Remove waiting-for-author label
if: >-
steps.checkUserMember.outputs.isTeamMember == 'false' &&
steps.extract_board_column.outputs.issue_board_column == 'Waiting for Author'
uses: andymckay/labeler@3a4296e9dcdf9576b0456050db78cfd34853f260
with:
remove-labels: 'waiting-for-author, no-activity'
repo-token: ${{ secrets.ORG_AUTOMATION_TOKEN }}
- name: Move to waiting for engineering column
if: ${{ steps.checkUserMember.outputs.isTeamMember == 'false'
&& steps.extract_board_column.outputs.issue_board_column == 'Waiting for Author' }}
uses: leonsteinhaeuser/project-beta-automations@v2.0.0
with:
gh_token: ${{ secrets.ORG_AUTOMATION_TOKEN }}
organization: timescale
project_id: 55
resource_node_id: ${{ github.event.issue.node_id }}
status_value: 'Waiting for Engineering'