File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 29
29
| username | Obtained from the context by default, can also be customized to pass in | string | ✖ |
30
30
| check-bot | Check whether the user is a bot | boolean | ✖ |
31
31
| check-contributor | Check whether the user is contributor | boolean | ✖ |
32
+ | error-if-missing | Error if require or check if false | boolean | ✖ |
32
33
33
34
- User permission: ` admin` > `write` > `read`
34
35
- ` username` support [github context](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context)
Original file line number Diff line number Diff line change @@ -50,33 +50,42 @@ async function run() {
50
50
return contributors ;
51
51
}
52
52
53
- if ( checkBot == 'true' ) {
53
+ if ( checkBot === 'true' ) {
54
54
const { data } = await octokit . users . getByUsername ( {
55
55
username,
56
56
} ) ;
57
57
if ( data . type === 'Bot' ) {
58
58
checkResult = true ;
59
59
}
60
- } else if ( checkContributor == 'true' ) {
60
+ } else if ( checkContributor === 'true' ) {
61
61
let contributors = await queryContributors ( ) ;
62
62
contributors = contributors . map ( ( { login } ) => login ) ;
63
63
if ( contributors . length ) {
64
64
checkResult = contributors . includes ( username ) ;
65
65
}
66
66
}
67
67
68
+ checkFailed = false ;
68
69
if ( checkBot || checkContributor ) {
69
70
core . info ( `[Action Check] The check result is ${ checkResult } .` ) ;
70
71
core . setOutput ( 'check-result' , checkResult ) ;
72
+ checkFailed = checkFailed || ! checkResult ;
71
73
}
72
74
73
75
if ( require ) {
74
76
requireResult = checkPermission ( require , permission ) ;
75
77
core . info ( `[Action Require] The ${ username } permission check is ${ requireResult } .` ) ;
76
78
core . setOutput ( 'require-result' , requireResult ) ;
79
+ checkFailed = checkFailed || ! requireResult ;
80
+ }
81
+
82
+ const errorIfMissing = core . getInput ( 'error-if-missing' ) ;
83
+ if ( checkFailed && ( errorIfMissing === 'true' ) ) {
84
+ core . setFailed ( 'The required check failed.' ) ;
77
85
}
78
86
79
87
core . info ( THANKS ) ;
88
+
80
89
} catch ( error ) {
81
90
core . setFailed ( error . message ) ;
82
91
}
You can’t perform that action at this time.
0 commit comments