File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
.github/actions/issue-limit Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
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 ( ) ;
You can’t perform that action at this time.
0 commit comments