Skip to content

Commit d5177b5

Browse files
Merge pull request #293 from technote-space/release/next-v3.1.2
release: v3.2.0
2 parents ede2c51 + f698eb4 commit d5177b5

File tree

4 files changed

+251
-229
lines changed

4 files changed

+251
-229
lines changed

__tests__/context-helper.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import {testEnv, getContext} from '@technote-space/github-action-test-helper';
88
import {Logger, ContextHelper} from '../src';
99

10-
const {isRelease, isPush, isPr, isIssue, isCron, isCustomEvent, isManualEvent, isCreateTag} = ContextHelper;
10+
const {isRelease, isPush, isPr, isIssue, isCron, isCustomEvent, isManualEvent, isWorkflowRun, isCreateTag} = ContextHelper;
1111
const {getGitUrl, getRepository, getTagName, getSender, showActionInfo} = ContextHelper;
1212

1313
describe('isRelease', () => {
@@ -39,12 +39,18 @@ describe('isPush', () => {
3939
});
4040

4141
describe('isPr', () => {
42-
it('should return true', () => {
42+
it('should return true 1', () => {
4343
expect(isPr(getContext({
4444
eventName: 'pull_request',
4545
}))).toBe(true);
4646
});
4747

48+
it('should return true 2', () => {
49+
expect(isPr(getContext({
50+
eventName: 'pull_request_target',
51+
}))).toBe(true);
52+
});
53+
4854
it('should return false', () => {
4955
expect(isPr(getContext({
5056
eventName: 'release',
@@ -108,6 +114,20 @@ describe('isManualEvent', () => {
108114
});
109115
});
110116

117+
describe('isWorkflowRun', () => {
118+
it('should return true', () => {
119+
expect(isWorkflowRun(getContext({
120+
eventName: 'workflow_run',
121+
}))).toBe(true);
122+
});
123+
124+
it('should return false', () => {
125+
expect(isWorkflowRun(getContext({
126+
eventName: 'release',
127+
}))).toBe(false);
128+
});
129+
});
130+
111131
describe('isCreateTag', () => {
112132
it('should return true', () => {
113133
expect(isCreateTag(getContext({

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/github-action-helper",
3-
"version": "3.1.2",
3+
"version": "3.2.0",
44
"description": "Helper to filter GitHub Action.",
55
"author": {
66
"name": "Technote",
@@ -35,15 +35,15 @@
3535
"devDependencies": {
3636
"@commitlint/cli": "^9.1.1",
3737
"@commitlint/config-conventional": "^9.1.1",
38-
"@technote-space/github-action-test-helper": "^0.5.4",
39-
"@types/jest": "^26.0.7",
38+
"@technote-space/github-action-test-helper": "^0.5.5",
39+
"@types/jest": "^26.0.8",
4040
"@types/node": "^14.0.27",
41-
"@typescript-eslint/eslint-plugin": "^3.7.1",
42-
"@typescript-eslint/parser": "^3.7.1",
43-
"eslint": "^7.5.0",
41+
"@typescript-eslint/eslint-plugin": "^3.8.0",
42+
"@typescript-eslint/parser": "^3.8.0",
43+
"eslint": "^7.6.0",
4444
"husky": "^4.2.5",
45-
"jest": "^26.2.1",
46-
"jest-circus": "^26.2.1",
45+
"jest": "^26.2.2",
46+
"jest-circus": "^26.2.2",
4747
"lint-staged": "^10.2.11",
4848
"nock": "^13.0.3",
4949
"ts-jest": "^26.1.4",

src/context-helper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const isRelease = (context: Context): boolean => 'release' === context.ev
77

88
export const isPush = (context: Context): boolean => 'push' === context.eventName;
99

10-
export const isPr = (context: Context): boolean => 'pull_request' === context.eventName;
10+
export const isPr = (context: Context): boolean => 'pull_request' === context.eventName || 'pull_request_target' === context.eventName;
1111

1212
export const isIssue = (context: Context): boolean => 'issues' === context.eventName;
1313

@@ -17,6 +17,8 @@ export const isCustomEvent = (context: Context): boolean => 'repository_dispatch
1717

1818
export const isManualEvent = (context: Context): boolean => 'workflow_dispatch' === context.eventName;
1919

20+
export const isWorkflowRun = (context: Context): boolean => 'workflow_run' === context.eventName;
21+
2022
export const isCreateTag = (context: Context): boolean => 'create' === context.eventName && 'tag' === context.payload.ref_type;
2123

2224
export const getTagName = (context: Context): string => isRelease(context) ? context.payload.release.tag_name : (/^refs\/tags\//.test(context.ref) ? context.ref.replace(/^refs\/tags\//, '') : '');

0 commit comments

Comments
 (0)