-
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (79 loc) · 3.13 KB
/
ci-test1.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
# # A github action to check the reaction on pr and issues .
name: Check Reactions on Pr and Issue
on:
issues:
types: [opened]
pull_request:
types: [opened, closed]
jobs:
check-reactions:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Add label to issues with more than 5 reactions
uses: actions/github-script@v6
with:
github-token: ${{ secrets.test_token }}
script: |
const { owner, repo } = context.repo;
// Check issues with more than 5 reactions
const issues = await github.paginate(github.rest.issues.listForRepo.endpoint({
owner,
repo,
state: 'open',
}));
for (const issue of issues) {
console.log(`Checking issue #${issue.number}`);
if (issue.reactions && issue.reactions.total_count > 5) {
console.log(`Issue #${issue.number} has ${issue.reactions.total_count} reactions`);
await github.rest.issues.addLabels({
owner,
repo,
issue_number: issue.number,
labels: ['community-attention'],
});
}
// Check comments on issue with more than 5 reactions
const comments = await github.paginate(github.rest.issues.listComments.endpoint({
owner,
repo,
issue_number: issue.number,
per_page: 100,
}));
for (const comment of comments) {
console.log(`Checking comment ${comment.id} on issue #${issue.number}`);
const reactions = await github.rest.reactions.listForIssueComment({
owner,
repo,
comment_id: comment.id,
});
if (reactions && reactions.total_count > 5) {
console.log(`Comment ${comment.id} on issue #${issue.number} has ${reactions.total_count} reactions`);
await github.rest.issues.addLabels({
owner,
repo,
issue_number: issue.number,
labels: ['community-attention'],
});
}
}
}
// Check pull requests with more than 5 reactions
const pulls = await github.paginate(github.rest.pulls.list.endpoint({
owner,
repo,
state: 'open',
}));
for (const pull of pulls) {
console.log(`Checking pull request #${pull.number}`);
if (pull.reactions && pull.reactions.total_count > 5) {
console.log(`Pull request #${pull.number} has ${pull.reactions.total_count} reactions`);
await github.rest.issues.addLabels({
owner,
repo,
issue_number: pull.number,
labels: ['community-attention'],
});
}
}