forked from eclipse-openj9/openj9
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.92 KB
/
TriageClosedIssue.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
name: Triager on Closed issues
run-name: TriagerX for closed Issue
on:
issues:
types: [closed]
jobs:
issue_closed:
name: Issue Closed
runs-on: ubuntu-latest
steps:
- name: Commenting on the issue
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: issueData } = await github.issues.get({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
const commentsUrl = issueData.comments_url;
const { data: commentsData } = await github.request(commentsUrl);
const sandboxOwner = context.repo.owner;
const sandboxRepo = context.repo.repo;
const actualLabels = issueData.labels.map(label => label['name']);
let resultString = `Issue Number: ${context.issue.number}\n`;
resultString += 'Status: Closed\n';
if (actualLabels.length > 0) {
resultString += `Actual Components: ${actualLabels.join(', ')}\n`;
} else {
resultString += `Actual Components: None :(\n`;
}
// Check if there is a closed/merged pull request associated with the issue
// Check if the pull request has been merged
let actualAssignees = [];
const timeline = await github.issues.listEventsForTimeline({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
let prAssignees = [];
timeline.data.forEach(event => {
if (event.event === 'cross-referenced' && event.source && event.source.issue.pull_request) {
const pr = event.source.issue;
if (pr.state === 'closed' || pr.merged === true) {
prAssignees.push(pr.user.login);
}
}
});
if (issueData.assignees.length != 0) {
const assignees = issueData.assignees.map(assignee => assignee.login);
actualAssignees.concat(assignees);
}
if (actualAssignees.length > 0) {
resultString += `Actual Assignees: ${actualAssignees.join(', ')}\n`;
} else {
resultString += `Actual Assignees: No one :(\n`;
}
if (prAssignees.length > 0) {
let prUniqueAssignees = [...new Set(prAssignees)];
resultString += `PR Assignees: ${prUniqueAssignees.join(', ')}`;
} else {
resultString += `PR Assignees: No one :(`;
}
await github.issues.createComment({
issue_number: context.issue.number,
owner: sandboxOwner,
repo: sandboxRepo,
body: resultString,
body: resultString,
});