-
Notifications
You must be signed in to change notification settings - Fork 99
55 lines (47 loc) · 1.58 KB
/
issue-check.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
name: Issue Check
on:
issues:
types: [opened, reopened]
jobs:
check-stargazer:
runs-on: ubuntu-latest
steps:
- name: Check if issue creator is a stargazer
uses: actions/github-script@v7
with:
script: |
const creator = context.payload.issue.user.login;
const owner = context.repo.owner;
const repo = context.repo.repo;
async function checkAllStargazers(owner, repo, creator) {
let page = 1;
while (true) {
const { data: stargazers } = await github.rest.activity.listStargazersForRepo({
owner,
repo,
per_page: 100,
page: page
});
if (stargazers.length === 0) {
break;
}
if (stargazers.some(user => user.login === creator)) {
return true;
}
page++;
}
return false;
}
try {
const hasStarred = await checkAllStargazers(owner, repo, creator);
if (!hasStarred) {
await github.rest.issues.addLabels({
owner,
repo,
issue_number: context.issue.number,
labels: ['invalid']
});
}
} catch (error) {
console.error('Error checking stargazer status:', error);
}