File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 2929| username | Obtained from the context by default, can also be customized to pass in | string | ✖ |
3030| check-bot | Check whether the user is a bot | boolean | ✖ |
3131| check-contributor | Check whether the user is contributor | boolean | ✖ |
32+ | error-if-missing | Error if require or check if false | boolean | ✖ |
3233
3334- User permission: ` admin` > `write` > `read`
3435- ` 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,30 +50,38 @@ async function run() {
5050 return contributors ;
5151 }
5252
53- if ( checkBot == 'true' ) {
53+ if ( checkBot === 'true' ) {
5454 const { data } = await octokit . users . getByUsername ( {
5555 username,
5656 } ) ;
5757 if ( data . type === 'Bot' ) {
5858 checkResult = true ;
5959 }
60- } else if ( checkContributor == 'true' ) {
60+ } else if ( checkContributor === 'true' ) {
6161 let contributors = await queryContributors ( ) ;
6262 contributors = contributors . map ( ( { login } ) => login ) ;
6363 if ( contributors . length ) {
6464 checkResult = contributors . includes ( username ) ;
6565 }
6666 }
6767
68+ checkFailed = false ;
6869 if ( checkBot || checkContributor ) {
6970 core . info ( `[Action Check] The check result is ${ checkResult } .` ) ;
7071 core . setOutput ( 'check-result' , checkResult ) ;
72+ checkFailed = checkFailed || ! checkResult ;
7173 }
7274
7375 if ( require ) {
7476 requireResult = checkPermission ( require , permission ) ;
7577 core . info ( `[Action Require] The ${ username } permission check is ${ requireResult } .` ) ;
7678 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.' ) ;
7785 }
7886
7987 core . info ( THANKS ) ;
You can’t perform that action at this time.
0 commit comments