-
Notifications
You must be signed in to change notification settings - Fork 144
62 lines (61 loc) · 2.14 KB
/
check-issue-status.yml
File metadata and controls
62 lines (61 loc) · 2.14 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
---
name: Check if datadog member commented an issue
on:
issue_comment:
types: [created]
jobs:
check_comment:
runs-on: ubuntu-latest
if: github.event.issue.pull_request == null
steps:
- name: Check if there is a comment from a datadog member
id: datadog-comment
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
result-encoding: string
script: |
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
let commented = "false";
for (const comment of comments.data) {
try {
const membership = await github.rest.orgs.checkMembershipForUser({
org: 'datadog',
username: comment.user.login
});
if (membership.status === 204) {
commented = "true";
break;
}
} catch (error) {
if (error.name === 'HttpError') {
// User is not a datadog member
continue;
}
throw error;
}
}
return commented;
- name: Remove the pending label when issue is commented
if: steps.datadog-comment.outputs.result == 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const labels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
for (const label of labels.data) {
if (label.name === 'pending') {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: label.name
});
}
}