Skip to content

Commit 33d3e39

Browse files
feat(*): next try
1 parent 9ed21f4 commit 33d3e39

3 files changed

Lines changed: 9 additions & 29 deletions

File tree

lib/main.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,19 @@ async function run() {
5656
core.setFailed(`no implementation for event name ${eventName}`);
5757
return;
5858
}
59-
core.info(`sha: ${sha}`);
6059
if (sha) {
61-
// const commitMessage = execSync(`git log --format=%B -n 1 ${sha}`, { encoding: 'utf8' }).trim()
62-
// const q = `hash:${sha}`
63-
// console.info(`q: ${q}`)
64-
// const response = await fetch(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, { headers: new Headers({ Authorization: `token ${ghToken}` }) })
65-
// if (response.status >= 200 && response.status < 300) {
66-
// // ok
67-
// const commit = await response.json() as { message: string }
68-
// const commitMessage = commit.message as string
6960
const url = `https://api.github.com/repos/${github.context.payload.repository?.full_name}/git/commits/${sha}`;
70-
console.log('fetch with url', url);
61+
core.info(`fetch commit with url: ${url}`);
7162
const commit = (await fetch(url, ghToken)); /* and others */
7263
const commitMessage = commit.message;
7364
core.info(`commit message to check against ${commitMessage}`);
7465
if (commitMessage.includes(skipOnCommitMsg)) {
66+
core.info(`commit message includes skip message (${skipOnCommitMsg}) -> set output ${OUTPUT_PARAMS.SHOULD_EXECUTE} = false`);
7567
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false);
7668
return;
7769
}
78-
// } else {
79-
// core.setFailed(`could not find commit for sha ${sha} -> got status code ${response.status}: ${response.statusText}`)
80-
// }
8170
}
71+
core.info(`commit message does not include skip message (${skipOnCommitMsg}) -> set output ${OUTPUT_PARAMS.SHOULD_EXECUTE} = true`);
8272
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true);
8373
}
8474
catch (error) {

src/main.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
3-
import { execSync } from 'child_process'
43
import https from 'https'
54

65
enum 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

8272
async function fetch(url, token) {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
2121
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
2222
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
23-
"lib": [],
23+
// "lib": [],
2424
/* Strict Type-Checking Options */
2525
"strict": true, /* Enable all strict type-checking options. */
2626
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */

0 commit comments

Comments
 (0)