Skip to content
This repository was archived by the owner on May 15, 2021. It is now read-only.

Commit 3ada497

Browse files
feat: build for release
1 parent 42a8c0c commit 3ada497

File tree

6 files changed

+36
-17
lines changed

6 files changed

+36
-17
lines changed

build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"owner":"technote-space","repo":"auto-cancel-redundant-job","sha":"c5edcc996aa699ea7a35800c01bc69a076d29e08","ref":"refs/tags/test/v1.5.1.287638925","tagName":"test/v1.5.1.287638925","branch":"gh-actions","tags":["test/v1.5.1.287638925","test/v1.5.1","test/v1.5","test/v1"],"updated_at":"2020-10-04T09:08:56.602Z"}
1+
{"owner":"technote-space","repo":"auto-cancel-redundant-job","sha":"FETCH_HEAD","ref":"refs/heads/master","tagName":"test/v1.5.1","branch":"gh-actions","tags":["test/v1.5.1","test/v1.5","test/v1"],"updated_at":"2020-10-07T07:20:22.376Z"}

lib/constant.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.SHOW_PROPERTIES = void 0;
4+
exports.SHOW_PROPERTIES = [
5+
'id',
6+
'head_branch',
7+
'head_sha',
8+
'run_number',
9+
'event',
10+
'status',
11+
'created_at',
12+
];

lib/process.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ exports.execute = (logger, octokit, context) => __awaiter(void 0, void 0, void 0
2121
}
2222
const runId = misc_1.getRunId();
2323
logger.info('run id: %d', runId);
24-
const workflowId = yield workflow_1.getWorkflowId(octokit, context);
24+
const run = yield workflow_1.getWorkflowRun(octokit, context);
25+
logger.startProcess('run:');
26+
console.log(misc_1.getFilteredRun(run));
27+
logger.endProcess();
28+
const workflowId = yield workflow_1.getWorkflowId(run);
2529
logger.info('workflow id: %d', workflowId);
2630
const runs = yield workflow_1.getWorkflowRuns(workflowId, logger, octokit, context);
31+
logger.startProcess('workflow runs:');
32+
console.log(runs.map(run => misc_1.getFilteredRun(run)));
33+
logger.endProcess();
2734
logger.log();
28-
const currentRun = runs.find(run => run.id === runId);
29-
if (!currentRun) {
30-
logger.info(logger.c('current run not found', { color: 'yellow' }));
31-
core_1.setOutput('ids', '');
32-
return;
33-
}
3435
const runsWithCreatedAtTime = runs.filter(run => run.id !== runId).map(run => (Object.assign(Object.assign({}, run), { createdAt: Date.parse(run.created_at) })));
35-
const createdAt = Date.parse(currentRun.created_at);
36+
const createdAt = Date.parse(workflow_1.getWorkflowRunCreatedAt(run));
3637
if (runsWithCreatedAtTime.find(run => run.createdAt > createdAt)) {
3738
logger.info(logger.c('newer job exists', { color: 'yellow' }));
3839
core_1.setOutput('ids', '');

lib/utils/misc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
99
});
1010
};
1111
Object.defineProperty(exports, "__esModule", { value: true });
12-
exports.getTargetBranch = exports.getRunId = exports.isNotExcludeRun = exports.isExcludeContext = void 0;
12+
exports.getFilteredRun = exports.getTargetBranch = exports.getRunId = exports.isNotExcludeRun = exports.isExcludeContext = void 0;
1313
const core_1 = require("@actions/core");
1414
const github_action_helper_1 = require("@technote-space/github-action-helper");
15+
const constant_1 = require("../constant");
1516
const getMergeMessagePrefix = () => github_action_helper_1.Utils.getPrefixRegExp(core_1.getInput('MERGE_MESSAGE_PREFIX'));
1617
const isExcludeMerged = () => github_action_helper_1.Utils.getBoolValue(core_1.getInput('EXCLUDE_MERGED'));
1718
const isExcludeTagPush = () => github_action_helper_1.Utils.getBoolValue(core_1.getInput('EXCLUDE_TAG_PUSH'));
@@ -25,3 +26,5 @@ exports.getTargetBranch = (octokit, context) => __awaiter(void 0, void 0, void 0
2526
}
2627
return github_action_helper_1.Utils.getBranch(context) || undefined;
2728
});
29+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
30+
exports.getFilteredRun = (run) => Object.assign({}, ...constant_1.SHOW_PROPERTIES.map(key => ({ [key]: run[key] })));

lib/utils/workflow.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
99
});
1010
};
1111
Object.defineProperty(exports, "__esModule", { value: true });
12-
exports.cancelWorkflowRun = exports.getWorkflowRuns = exports.getWorkflowId = void 0;
12+
exports.cancelWorkflowRun = exports.getWorkflowRuns = exports.getWorkflowRunCreatedAt = exports.getWorkflowId = exports.getWorkflowRun = void 0;
1313
const misc_1 = require("./misc");
14-
exports.getWorkflowId = (octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
15-
const run = yield octokit.actions.getWorkflowRun({
14+
exports.getWorkflowRun = (octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
15+
return (yield octokit.actions.getWorkflowRun({
1616
owner: context.repo.owner,
1717
repo: context.repo.repo,
1818
'run_id': Number(process.env.GITHUB_RUN_ID),
19-
});
20-
const matches = run.data.workflow_url.match(/\d+$/);
19+
})).data;
20+
});
21+
exports.getWorkflowId = (run) => {
22+
const matches = run.workflow_url.match(/\d+$/);
2123
if (!matches) {
2224
throw new Error('Invalid workflow run');
2325
}
2426
return Number(matches[0]);
25-
});
27+
};
28+
exports.getWorkflowRunCreatedAt = (run) => run.created_at;
2629
exports.getWorkflowRuns = (workflowId, logger, octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
2730
const options = Object.assign(Object.assign({}, context.repo), { 'workflow_id': workflowId, status: 'in_progress', event: context.eventName });
2831
const branch = yield misc_1.getTargetBranch(octokit, context);

node_modules/.yarn-integrity

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)