Skip to content

Commit 3897c66

Browse files
feat: consider workflow run event
1 parent d99c983 commit 3897c66

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

__tests__/context-helper.test.ts

Lines changed: 15 additions & 1 deletion
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', () => {
@@ -114,6 +114,20 @@ describe('isManualEvent', () => {
114114
});
115115
});
116116

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+
117131
describe('isCreateTag', () => {
118132
it('should return true', () => {
119133
expect(isCreateTag(getContext({

src/context-helper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)