8000 feat(*): next try · shiftcode/github-action-skip@3aafbe7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3aafbe7

Browse files
feat(*): next try
1 parent 910e3c3 commit 3aafbe7

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

lib/main.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
2121
Object.defineProperty(exports, "__esModule", { value: true });
2222
const core = __importStar(require("@actions/core"));
2323
const github = __importStar(require("@actions/github"));
24-
const node_fetch_1 = __importStar(require("node-fetch"));
24+
const child_process_1 = require("child_process");
2525
var INPUT_PARAMS;
2626
(function (INPUT_PARAMS) {
2727
INPUT_PARAMS["SKIP_ON_COMMIT_MSG"] = "skipOnCommitMsg";
@@ -55,22 +55,22 @@ async function run() {
5555
}
5656
core.info(`sha: ${sha}`);
5757
if (sha) {
58-
const q = `hash:${sha}`;
59-
console.info(`q: ${q}`);
60-
const response = await (0, node_fetch_1.default)(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, { headers: new node_fetch_1.Headers({ Authorization: `token ${ghToken}` }) });
61-
if (response.status >= 200 && response.status < 300) {
62-
// ok
63-
const commit = await response.json();
64-
const commitMessage = commit.message;
65-
core.info(`commit message to check against ${commitMessage}`);
66-
if (commitMessage.includes(skipOnCommitMsg)) {
67-
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false);
68-
return;
69-
}
70-
}
71-
else {
72-
core.setFailed(`could not find commit for sha ${sha} -> got status code ${response.status}: ${response.statusText}`);
58+
const commitMessage = (0, child_process_1.execSync)(`git log --format=%B -n 1 ${sha}`, { encoding: 'utf8' }).trim();
59+
// const q = `hash:${sha}`
60+
// console.info(`q: ${q}`)
61+
// const response = await fetch(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, { headers: new Headers({ Authorization: `token ${ghToken}` }) })
62+
// if (response.status >= 200 && response.status < 300) {
63+
// // ok
64+
// const commit = await response.json() as { message: string }
65+
// const commitMessage = commit.message as string
66+
core.info(`commit message to check against ${commitMessage}`);
67+
if (commitMessage.includes(skipOnCommitMsg)) {
68+
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false);
69+
return;
7370
}
71+
// } else {
72+
// core.setFailed(`could not find commit for sha ${sha} -> got status code ${response.status}: ${response.statusText}`)
73+
// }
7474
}
7575
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true);
7676
}

src/main.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
3-
import fetch, { Headers } from 'node-fetch'
3+
import { execSync } from 'child_process'
44

55
enum INPUT_PARAMS {
66
SKIP_ON_COMMIT_MSG = 'skipOnCommitMsg',
@@ -39,22 +39,23 @@ async function run() {
3939

4040
core.info(`sha: ${sha}`)
4141
if (sha) {
42-
const q = `hash:${sha}`
43-
console.info(`q: ${q}`)
44-
const response = await fetch(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, { headers: new Headers({ Authorization: `token ${ghToken}` }) })
45-
if (response.status >= 200 && response.status < 300) {
46-
// ok
47-
const commit = await response.json() as { message: string }
48-
const commitMessage = commit.message as string
42+
const commitMessage = execSync(`git log --format=%B -n 1 ${sha}`, { encoding: 'utf8' }).trim()
43+
// const q = `hash:${sha}`
44+
// console.info(`q: ${q}`)
45+
// const response = await fetch(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, { headers: new Headers({ Authorization: `token ${ghToken}` }) })
46+
// if (response.status >= 200 && response.status < 300) {
47+
// // ok
48+
// const commit = await response.json() as { message: string }
49+
// const commitMessage = commit.message as string
4950
core.info(`commit message to check against ${commitMessage}`)
5051

5152
if (commitMessage.includes(skipOnCommitMsg)) {
5253
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false)
5354
return
5455
}
55-
} else {
56-
core.setFailed(`could not find commit for sha ${sha} -> got status code ${response.status}: ${response.statusText}`)
57-
}
56+
// } else {
57+
// core.setFailed(`could not find commit for sha ${sha} -> got status code ${response.status}: ${response.statusText}`)
58+
// }
5859
}
5960

6061
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true)

0 commit comments

Comments
 (0)
0