Skip to content

release: v3.2.0 #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions __tests__/context-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import {testEnv, getContext} from '@technote-space/github-action-test-helper';
import {Logger, ContextHelper} from '../src';

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

describe('isRelease', () => {
Expand Down Expand Up @@ -39,12 +39,18 @@ describe('isPush', () => {
});

describe('isPr', () => {
it('should return true', () => {
it('should return true 1', () => {
expect(isPr(getContext({
eventName: 'pull_request',
}))).toBe(true);
});

it('should return true 2', () => {
expect(isPr(getContext({
eventName: 'pull_request_target',
}))).toBe(true);
});

it('should return false', () => {
expect(isPr(getContext({
eventName: 'release',
Expand Down Expand Up @@ -108,6 +114,20 @@ describe('isManualEvent', () => {
});
});

describe('isWorkflowRun', () => {
it('should return true', () => {
expect(isWorkflowRun(getContext({
eventName: 'workflow_run',
}))).toBe(true);
});

it('should return false', () => {
expect(isWorkflowRun(getContext({
eventName: 'release',
}))).toBe(false);
});
});

describe('isCreateTag', () => {
it('should return true', () => {
expect(isCreateTag(getContext({
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@technote-space/github-action-helper",
"version": "3.1.2",
"version": "3.2.0",
"description": "Helper to filter GitHub Action.",
"author": {
"name": "Technote",
Expand Down Expand Up @@ -35,15 +35,15 @@
"devDependencies": {
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@technote-space/github-action-test-helper": "^0.5.4",
"@types/jest": "^26.0.7",
"@technote-space/github-action-test-helper": "^0.5.5",
"@types/jest": "^26.0.8",
"@types/node": "^14.0.27",
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"eslint": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"husky": "^4.2.5",
"jest": "^26.2.1",
"jest-circus": "^26.2.1",
"jest": "^26.2.2",
"jest-circus": "^26.2.2",
"lint-staged": "^10.2.11",
"nock": "^13.0.3",
"ts-jest": "^26.1.4",
Expand Down
4 changes: 3 additions & 1 deletion src/context-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const isRelease = (context: Context): boolean => 'release' === context.ev

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

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

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

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

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

export const isWorkflowRun = (context: Context): boolean => 'workflow_run' === context.eventName;

export const isCreateTag = (context: Context): boolean => 'create' === context.eventName && 'tag' === context.payload.ref_type;

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