11import * as core from '@actions/core'
22import * as github from '@actions/github'
3- import { execSync } from 'child_process'
43import https from 'https'
54
65enum INPUT_PARAMS {
@@ -38,32 +37,22 @@ async function run() {
3837 return
3938 }
4039
41- core . info ( `sha: ${ sha } ` )
4240 if ( sha ) {
43- // const commitMessage = execSync(`git log --format=%B -n 1 ${sha}`, { encoding: 'utf8' }).trim()
44- // const q = `hash:${sha}`
45- // console.info(`q: ${q}`)
46- // const response = await fetch(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, { headers: new Headers({ Authorization: `token ${ghToken}` }) })
47- // if (response.status >= 200 && response.status < 300) {
48- // // ok
49- // const commit = await response.json() as { message: string }
50- // const commitMessage = commit.message as string
5141 const url = `https://api.github.com/repos/${ github . context . payload . repository ?. full_name } /git/commits/${ sha } `
52- console . log ( ' fetch with url' , url )
53- const commit = ( await fetch ( url , ghToken ) ) as { sha : string , url : string , message : string } /* and others */
42+ core . info ( ` fetch commit with url: ${ url } ` )
43+ const commit = ( await fetch ( url , ghToken ) ) as { message : string } /* and others */
5444
5545 const commitMessage = commit . message
5646 core . info ( `commit message to check against ${ commitMessage } ` )
5747
5848 if ( commitMessage . includes ( skipOnCommitMsg ) ) {
49+ core . info ( `commit message includes skip message (${ skipOnCommitMsg } ) -> set output ${ OUTPUT_PARAMS . SHOULD_EXECUTE } = false` )
5950 core . setOutput ( OUTPUT_PARAMS . SHOULD_EXECUTE , false )
6051 return
6152 }
62- // } else {
63- // core.setFailed(`could not find commit for sha ${sha} -> got status code ${response.status}: ${response.statusText}`)
64- // }
6553 }
6654
55+ core . info ( `commit message does not include skip message (${ skipOnCommitMsg } ) -> set output ${ OUTPUT_PARAMS . SHOULD_EXECUTE } = true` )
6756 core . setOutput ( OUTPUT_PARAMS . SHOULD_EXECUTE , true )
6857 } catch ( error ) {
6958 core . error ( 'there was an error' )
@@ -77,6 +66,7 @@ async function run() {
7766 core . setFailed ( `there was an error, can't print JSON.stringify failed` )
7867 }
7968 }
69+
8070}
8171
8272async function fetch ( url , token ) {
0 commit comments