Skip to content

Commit 27bb6a5

Browse files
authored
Create index.js
1 parent 8530510 commit 27bb6a5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/actions/issue-limit/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const core = require('@actions/core');
2+
const github = require('@actions/github');
3+
4+
async function run() {
5+
try {
6+
const token = core.getInput('GITHUB_TOKEN');
7+
const octokit = github.getOctokit(token);
8+
const { owner, repo } = github.context.repo;
9+
const creator = github.context.payload.issue.user.login;
10+
11+
const { data: issues } = await octokit.rest.issues.listForRepo({
12+
owner,
13+
repo,
14+
state: 'open',
15+
creator
16+
});
17+
18+
if (issues.length >= 4) {
19+
const issueNumber = github.context.payload.issue.number;
20+
await octokit.rest.issues.update({
21+
owner,
22+
repo,
23+
issue_number: issueNumber,
24+
state: 'closed'
25+
});
26+
core.setFailed(`User ${creator} has exceeded the limit of 4 open issues.`);
27+
}
28+
} catch (error) {
29+
core.setFailed(error.message);
30+
}
31+
}
32+
33+
run();

0 commit comments

Comments
 (0)