forked from ankidroid/Anki-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (60 loc) · 2.28 KB
/
assignees.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
name: Remove Assignees
on:
pull_request_target:
types: [ closed ]
jobs:
merge_job:
if: ${{ github.event.pull_request.merged == true }}
permissions:
contents: read
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const variables = {
_url: "https://github.com/ankidroid/${{ github.event.repository.name }}/pull/${{ github.event.pull_request.number }}"
};
const query = `query($_url:URI!) {
resource(url:$_url) {
... on PullRequest {
closingIssuesReferences(first:10) {
nodes {
number
}
}
}
}
}`;
const result = await github.graphql(query, variables);
const refIssues = result.resource.closingIssuesReferences.nodes;
let listAssignees_result = await github.rest.issues.listAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
});
// remove all the assignees of the issue
if (listAssignees_result.data !== null && listAssignees_result.data.length > 0) {
let assignees_info_list = listAssignees_result.data;
let assignees_list=[];
for (let assignee_info of assignees_info_list) {
assignees_list.push(assignee_info["login"]);
}
await github.rest.issues.removeAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: assignees_list,
});
console.log("Removed Assignees in this pr#",context.issue.number);
for (issue of refIssues) {
await github.rest.issues.removeAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
assignees: assignees_list,
});
console.log("Removed Assignees in issue#",issue.number);
}
}