test: skipOnFork()

This commit is contained in:
peaceiris
2020-03-14 21:31:02 +00:00
parent 5c097c0f86
commit 6f9a5b7a66
3 changed files with 36 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
import {context} from '@actions/github';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {Inputs} from './interfaces';
@@ -11,7 +12,11 @@ export async function run(): Promise<void> {
const inps: Inputs = getInputs();
showInputs(inps);
const isForkRepository =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(context.payload as any).repository.fork === 'true';
const isSkipOnFork = await skipOnFork(
isForkRepository,
inps.GithubToken,
inps.DeployKey,
inps.PersonalToken

View File

@@ -1,4 +1,3 @@
import {context} from '@actions/github';
import * as core from '@actions/core';
import * as io from '@actions/io';
import path from 'path';
@@ -65,20 +64,17 @@ export async function addCNAME(
}
export async function skipOnFork(
isForkRepository: boolean,
githubToken: string,
deployKey: string,
personalToken: string
): Promise<boolean> {
const isForkRepository =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(context.payload as any).repository.fork === 'true';
if (isForkRepository) {
if (githubToken) {
return false;
}
if (!deployKey && !personalToken) {
if (deployKey === '' && personalToken === '') {
core.warning(
'Action runs on fork and deploy_key or personal_token is empty'
);