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

Skip to content

Commit 910e3c3

Browse files
feat(*): next try
1 parent 139d30b commit 910e3c3

26 files changed

+409
-84
lines changed

lib/lab.js

Lines changed: 50 additions & 0 deletions
Original file line number< 8000 /th>Diff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5+
}) : (function(o, m, k, k2) {
6+
if (k2 === undefined) k2 = k;
7+
o[k2] = m[k];
8+
}));
9+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10+
Object.defineProperty(o, "default", { enumerable: true, value: v });
11+
}) : function(o, v) {
12+
o["default"] = v;
13+
});
14+
var __importStar = (this && this.__importStar) || function (mod) {
15+
if (mod && mod.__esModule) return mod;
16+
var result = {};
17+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18+
__setModuleDefault(result, mod);
19+
return result;
20+
};
21+
Object.defineProperty(exports, "__esModule", { value: true });
22+
const rest_1 = require("@octokit/rest");
23+
const node_fetch_1 = __importStar(require("node-fetch"));
24+
run();
25+
async function run() {
26+
const o = new rest_1.Octokit({ auth: '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' });
27+
// const { data } = await o.request("/user");
28+
// console.log(data)
29+
const sha = 'fd3d6b191cf773f68ca6dfc57bc52e28513fd8d1';
30+
// const q = `repo:shiftcode/sc-commons next`
31+
// const q = `hash:${sha} repo:shiftcode/sc-commons rev:@*refs/heads/* type:diff`
32+
// const q = `repo:shiftcode/sc-commons@${sha} type:diff`
33+
// const q = `hash:${sha} rev:@*refs/heads/*`
34+
const q = `hash:${sha} repo:shiftcode/sc-commons rev:@refs/heads/#102-fix-peer-deps-version type:diff`;
35+
console.info(`q: ${q}`);
36+
const response = await o.rest.search.commits({ q });
37+
console.log(response);
38+
for (const { commit } of response.data.items) {
39+
console.log(`----------------- ${commit.url} -----------------`);
40+
console.log(commit.message);
41+
console.log('-------------------------------------------------');
42+
}
43+
const headers = new node_fetch_1.Headers();
44+
headers.set('Authorization', 'token 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');
45+
const response2 = await (0, node_fetch_1.default)(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, {
46+
headers
47+
});
48+
console.log(response2.status);
49+
console.log(await response2.json());
50+
}

lib/main.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +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"));
2425
var INPUT_PARAMS;
2526
(function (INPUT_PARAMS) {
2627
INPUT_PARAMS["SKIP_ON_COMMIT_MSG"] = "skipOnCommitMsg";
@@ -56,17 +57,19 @@ async function run() {
5657
if (sha) {
5758
const q = `hash:${sha}`;
5859
console.info(`q: ${q}`);
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;
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+
}
6470
}
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);
69-
return;
71+
else {
72+
core.setFailed(`could not find commit for sha ${sha} -> got status code ${response.status}: ${response.statusText}`);
7073
}
7174
}
7275
core.setOutput(OUTPUT_PARAMS.SHOULD_EXECUTE, true);

lib/octokit-lab.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5+
}) : (function(o, m, k, k2) {
6+
if (k2 === undefined) k2 = k;
7+
o[k2] = m[k];
8+
}));
9+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10+
Object.defineProperty(o, "default", { enumerable: true, value: v });
11+
}) : function(o, v) {
12+
o["default"] = v;
13+
});
14+
var __importStar = (this && this.__importStar) || function (mod) {
15+
if (mod && mod.__esModule) return mod;
16+
var result = {};
17+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18+
__setModuleDefault(result, mod);
19+
return result;
20+
};
21+
Object.defineProperty(exports, "__esModule", { value: true });
22+
const rest_1 = require("@octokit/rest");
23+
const node_fetch_1 = __importStar(require("node-fetch"));
24+
run();
25+
async function run() {
26+
const o = new rest_1.Octokit({ auth: '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' });
27+
// const { data } = await o.request("/user");
28+
// console.log(data)
29+
const sha = 'fd3d6b191cf773f68ca6dfc57bc52e28513fd8d1';
30+
// const q = `repo:shiftcode/sc-commons next`
31+
// const q = `hash:${sha} repo:shiftcode/sc-commons rev:@*refs/heads/* type:diff`
32+
// const q = `repo:shiftcode/sc-commons@${sha} type:diff`
33+
// const q = `hash:${sha} rev:@*refs/heads/*`
34+
const q = `hash:${sha} repo:shiftcode/sc-commons rev:@refs/heads/#102-fix-peer-deps-version type:diff`;
35+
console.info(`q: ${q}`);
36+
const response = await o.rest.search.commits({ q });
37+
console.log(response);
38+
for (const { commit } of response.data.items) {
39+
console.log(`----------------- ${commit.url} -----------------`);
40+
console.log(commit.message);
41+
console.log('-------------------------------------------------');
42+
}
43+
const headers = new node_fetch_1.Headers();
44+
headers.set('Authorization', 'token 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');
45+
const response2 = await (0, node_fetch_1.default)(`https://api.github.com/repos/shiftcode/sc-commons/git/commits/${sha}`, {
46+
headers
47+
});
48+
console.log(response2.status);
49+
console.log(await response2.json());
50+
}

node_modules/.package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0