Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee6484961d | ||
|
|
a8f525053d | ||
|
|
6f9a5b7a66 | ||
|
|
5c097c0f86 |
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [3.5.4-4](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-3...v3.5.4-4) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### test
|
||||||
|
|
||||||
|
* skipOnFork() ([6f9a5b7](https://github.com/peaceiris/actions-gh-pages/commit/6f9a5b7a66bbf855cadc34099fa6450c40eff4a2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [3.5.4-3](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-2...v3.5.4-3) (2020-03-14)
|
## [3.5.4-3](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-2...v3.5.4-3) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import {
|
|||||||
getWorkDirName,
|
getWorkDirName,
|
||||||
createWorkDir,
|
createWorkDir,
|
||||||
addNoJekyll,
|
addNoJekyll,
|
||||||
addCNAME
|
addCNAME,
|
||||||
|
skipOnFork
|
||||||
} from '../src/utils';
|
} from '../src/utils';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -203,3 +204,30 @@ describe('addCNAME()', () => {
|
|||||||
fs.unlinkSync(filepath);
|
fs.unlinkSync(filepath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('skipOnFork()', () => {
|
||||||
|
test('return false on upstream', async () => {
|
||||||
|
const test = await skipOnFork(false, 'token', '', '');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return false on fork with github_token', async () => {
|
||||||
|
const test = await skipOnFork(true, 'token', '', '');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return false on fork with deploy_key', async () => {
|
||||||
|
const test = await skipOnFork(true, '', 'deploy_key', '');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return false on fork with personal_token', async () => {
|
||||||
|
const test = await skipOnFork(true, '', '', 'personal_token');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return true on fork with empty deploy_key or personal_token', async () => {
|
||||||
|
const test = await skipOnFork(true, '', '', '');
|
||||||
|
expect(test).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
1390
lib/index.js
1390
lib/index.js
File diff suppressed because it is too large
Load Diff
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.5.4-3",
|
"version": "3.5.4-4",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.5.4-3",
|
"version": "3.5.4-4",
|
||||||
"description": "GitHub Actions for GitHub Pages",
|
"description": "GitHub Actions for GitHub Pages",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import {context} from '@actions/github';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import {Inputs} from './interfaces';
|
import {Inputs} from './interfaces';
|
||||||
@@ -11,7 +12,11 @@ export async function run(): Promise<void> {
|
|||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
|
|
||||||
|
const isForkRepository =
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
(context.payload as any).repository.fork === 'true';
|
||||||
const isSkipOnFork = await skipOnFork(
|
const isSkipOnFork = await skipOnFork(
|
||||||
|
isForkRepository,
|
||||||
inps.GithubToken,
|
inps.GithubToken,
|
||||||
inps.DeployKey,
|
inps.DeployKey,
|
||||||
inps.PersonalToken
|
inps.PersonalToken
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import {context} from '@actions/github';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -65,20 +64,17 @@ export async function addCNAME(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function skipOnFork(
|
export async function skipOnFork(
|
||||||
|
isForkRepository: boolean,
|
||||||
githubToken: string,
|
githubToken: string,
|
||||||
deployKey: string,
|
deployKey: string,
|
||||||
personalToken: string
|
personalToken: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const isForkRepository =
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(context.payload as any).repository.fork === 'true';
|
|
||||||
|
|
||||||
if (isForkRepository) {
|
if (isForkRepository) {
|
||||||
if (githubToken) {
|
if (githubToken) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deployKey && !personalToken) {
|
if (deployKey === '' && personalToken === '') {
|
||||||
core.warning(
|
core.warning(
|
||||||
'Action runs on fork and deploy_key or personal_token is empty'
|
'Action runs on fork and deploy_key or personal_token is empty'
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user