Skip to content

Commit 139d30b

Browse files
feat(*): next try
1 parent 27c576d commit 139d30b

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

lib/main.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async function run() {
4444
case 'pull_request':
4545
core.info(JSON.stringify(github.context.payload.pull_request));
4646
sha = github.context.payload.pull_request?.head.sha ?? `unknown`;
47+
break;
4748
case 'push':
4849
sha = github.context.sha;
4950
break;
@@ -55,18 +56,20 @@ async function run() {
5556
if (sha) {
5657
const q = `hash:${sha}`;
5758
console.info(`q: ${q}`);
58-
const response = await octokit.rest.search.commits({ q });
59-
core.info(`count of commits ${response.data.total_count}`);
60-
for (const { commit } of response.data.items) {
61-
core.info(`message: ${commit.url}`);
62-
core.info(`message: ${commit.message}`);
59+
const { data } = await octokit.rest.search.commits({ q });
60+
core.info(`found ${data.total_count} commits for sha ${sha}`);
61+
if (data.total_count === 0) {
62+
core.setFailed(`could not find commit with sha ${sha}`);
63+
return;
6364
}
64-
if (true) {
65-
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true);
65+
const commitMessage = data.items[0].commit.message;
66+
core.info(`commit message to check against ${commitMessage}`);
67+
if (commitMessage.includes(skipOnCommitMsg)) {
68+
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false);
6669
return;
6770
}
6871
}
69-
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false);
72+
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true);
7073
}
7174
catch (error) {
7275
core.error('there was an error');

src/main.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ async function run() {
2727
case 'pull_request':
2828
core.info(JSON.stringify(github.context.payload.pull_request))
2929
sha = github.context.payload.pull_request?.head.sha ?? `unknown`
30+
break
3031
case 'push':
3132
sha = github.context.sha
3233
break
@@ -39,20 +40,24 @@ async function run() {
3940
if (sha) {
4041
const q = `hash:${sha}`
4142
console.info(`q: ${q}`)
42-
const response = await octokit.rest.search.commits({ q })
43-
core.info(`count of commits ${response.data.total_count}`)
44-
for (const { commit } of response.data.items) {
45-
core.info(`message: ${commit.url}`)
46-
core.info(`message: ${commit.message}`)
43+
const { data } = await octokit.rest.search.commits({ q })
44+
core.info(`found ${data.total_count} commits for sha ${sha}`)
45+
46+
if (data.total_count === 0) {
47+
core.setFailed(`could not find commit with sha ${sha}`)
48+
return
4749
}
4850

49-
if (true) {
50-
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true)
51+
const commitMessage = data.items[0].commit.message as string
52+
core.info(`commit message to check against ${commitMessage}`)
53+
54+
if (commitMessage.includes(skipOnCommitMsg)) {
55+
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false)
5156
return
5257
}
5358
}
5459

55-
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, false)
60+
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true)
5661
} catch (error) {
5762
core.error('there was an error')
5863
if (error instanceof Error) {

0 commit comments

Comments
 (0)