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

Commit 39f7d58

Browse files
Merge pull request #56 from technote-space/release/next-v1.6.4
release: v1.6.5
2 parents 1651eff + 73aa98a commit 39f7d58

File tree

5 files changed

+253
-248
lines changed

5 files changed

+253
-248
lines changed

package.json

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/auto-cancel-redundant-workflow",
3-
"version": "1.6.4",
3+
"version": "1.6.5",
44
"description": "GitHub Actions to automatically cancel redundant workflow.",
55
"keywords": [
66
"github",
@@ -36,26 +36,27 @@
3636
"dependencies": {
3737
"@actions/core": "^1.2.6",
3838
"@actions/github": "^4.0.0",
39-
"@octokit/plugin-paginate-rest": "^2.6.0",
40-
"@octokit/plugin-rest-endpoint-methods": "^4.2.1",
41-
"@octokit/types": "^5.5.0",
42-
"@technote-space/github-action-helper": "^4.2.7",
43-
"@technote-space/github-action-log-helper": "^0.1.8"
39+
"@octokit/openapi-types": "^2.0.0",
40+
"@octokit/plugin-paginate-rest": "^2.6.2",
41+
"@octokit/plugin-rest-endpoint-methods": "^4.4.1",
42+
"@octokit/types": "^6.1.1",
43+
"@technote-space/github-action-helper": "^4.4.4",
44+
"@technote-space/github-action-log-helper": "^0.1.9"
4445
},
4546
"devDependencies": {
4647
"@commitlint/cli": "^11.0.0",
4748
"@commitlint/config-conventional": "^11.0.0",
48-
"@technote-space/github-action-test-helper": "^0.6.4",
49-
"@technote-space/release-github-actions-cli": "^1.7.2",
50-
"@types/jest": "^26.0.15",
51-
"@types/node": "^14.14.9",
52-
"@typescript-eslint/eslint-plugin": "^4.8.1",
53-
"@typescript-eslint/parser": "^4.8.1",
54-
"eslint": "^7.14.0",
55-
"husky": "^4.3.0",
49+
"@technote-space/github-action-test-helper": "^0.6.5",
50+
"@technote-space/release-github-actions-cli": "^1.7.3",
51+
"@types/jest": "^26.0.16",
52+
"@types/node": "^14.14.10",
53+
"@typescript-eslint/eslint-plugin": "^4.9.0",
54+
"@typescript-eslint/parser": "^4.9.0",
55+
"eslint": "^7.15.0",
56+
"husky": "^4.3.5",
5657
"jest": "^26.6.3",
5758
"jest-circus": "^26.6.3",
58-
"lint-staged": "^10.5.1",
59+
"lint-staged": "^10.5.3",
5960
"nock": "^13.0.5",
6061
"ts-jest": "^26.4.4",
6162
"typescript": "^4.1.2"

src/utils/misc.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import {getInput} from '@actions/core';
22
import {Context} from '@actions/github/lib/context';
33
import {Octokit} from '@technote-space/github-action-helper/dist/types';
44
import {ContextHelper, Utils} from '@technote-space/github-action-helper';
5-
import {ActionsListWorkflowRunsResponseData, ActionsGetWorkflowRunResponseData} from '@octokit/types';
5+
import {components} from '@octokit/openapi-types';
66
import {SHOW_PROPERTIES} from '../constant';
77

8+
type ActionsListWorkflowRunsResponseData = components['schemas']['workflow-run'];
9+
type ActionsGetWorkflowRunResponseData = components['schemas']['workflow-run'];
10+
811
const getMergeMessagePrefix = (): RegExp => Utils.getPrefixRegExp(getInput('MERGE_MESSAGE_PREFIX'));
912
const isExcludeMerged = (): boolean => Utils.getBoolValue(getInput('EXCLUDE_MERGED'));
1013
const isExcludeTagPush = (): boolean => Utils.getBoolValue(getInput('EXCLUDE_TAG_PUSH'));
@@ -13,7 +16,7 @@ export const isExcludeContext = (context: Context): boolean =>
1316
(isExcludeTagPush() && Utils.isTagRef(context)) ||
1417
(isExcludeMerged() && getMergeMessagePrefix().test(context.payload.head_commit.message))
1518
);
16-
export const isNotExcludeRun = (run: ActionsListWorkflowRunsResponseData['workflow_runs'][number]): boolean => !isExcludeMerged() || !getMergeMessagePrefix().test(run.head_commit.message);
19+
export const isNotExcludeRun = (run: ActionsListWorkflowRunsResponseData): boolean => !isExcludeMerged() || !getMergeMessagePrefix().test(run.head_commit.message);
1720

1821
export const getRunId = (): number => Number(process.env.GITHUB_RUN_ID);
1922

src/utils/workflow.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import {Context} from '@actions/github/lib/context';
22
import {Octokit} from '@technote-space/github-action-helper/dist/types';
33
import {Logger} from '@technote-space/github-action-log-helper';
4+
import {Utils} from '@technote-space/github-action-helper';
45
import {PaginateInterface} from '@octokit/plugin-paginate-rest';
56
import {RestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types';
6-
import {ActionsListWorkflowRunsResponseData, ActionsGetWorkflowRunResponseData} from '@octokit/types';
7+
import {components} from '@octokit/openapi-types';
78
import {getTargetBranch, isNotExcludeRun} from './misc';
89

10+
type ActionsGetWorkflowRunResponseData = components['schemas']['workflow-run'];
11+
type ActionsListWorkflowRunsResponseData = components['schemas']['workflow-run'];
12+
913
export const getWorkflowRun = async(octokit: Octokit, context: Context): Promise<ActionsGetWorkflowRunResponseData> => {
1014
return (await octokit.actions.getWorkflowRun({
1115
owner: context.repo.owner,
@@ -23,11 +27,11 @@ export const getWorkflowId = (run: ActionsGetWorkflowRunResponseData): number |
2327
return Number(matches[0]);
2428
};
2529

26-
export const getWorkflowRunCreatedAt = (run: ActionsGetWorkflowRunResponseData): string => run.created_at;
30+
export const getWorkflowRunCreatedAt = (run: ActionsGetWorkflowRunResponseData): string => Utils.ensureNotNull(run.created_at);
2731

2832
export const getWorkflowRunNumber = (run: ActionsGetWorkflowRunResponseData): number => run.run_number;
2933

30-
export const getWorkflowRuns = async(workflowId: number, logger: Logger, octokit: Octokit, context: Context): Promise<ActionsListWorkflowRunsResponseData['workflow_runs']> => {
34+
export const getWorkflowRuns = async(workflowId: number, logger: Logger, octokit: Octokit, context: Context): Promise<Array<ActionsListWorkflowRunsResponseData>> => {
3135
const options: {
3236
owner: string;
3337
repo: string;
@@ -57,7 +61,7 @@ export const getWorkflowRuns = async(workflowId: number, logger: Logger, octokit
5761
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5862
// @ts-ignore
5963
options,
60-
)).map(run => run as ActionsListWorkflowRunsResponseData['workflow_runs'][number]).filter(run => run.event === context.eventName).filter(isNotExcludeRun);
64+
)).map(run => run as ActionsListWorkflowRunsResponseData).filter(run => run.event === context.eventName).filter(isNotExcludeRun);
6165
};
6266

6367
// eslint-disable-next-line @typescript-eslint/no-explicit-any

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
/* Basic Options */
44
// "incremental": true, /* Enable incremental compilation */
5-
"target": "es6",
5+
"target": "ES2019",
66
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
77
"module": "commonjs",
88
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */

0 commit comments

Comments
 (0)