Compare commits

...

23 Commits

Author SHA1 Message Date
peaceiris
ee834289d5 chore(release): 3.5.4-5 2020-03-15 07:09:30 +09:00
peaceiris
a9077f3fa3 chore(release): Add build assets 2020-03-15 07:09:29 +09:00
peaceiris
72f58a06cf fix: property access 2020-03-14 22:09:05 +00:00
peaceiris
a8a9c90a27 chore(release): Remove build assets [skip ci] 2020-03-15 06:31:25 +09:00
peaceiris
ee6484961d chore(release): 3.5.4-4 2020-03-15 06:31:25 +09:00
peaceiris
a8f525053d chore(release): Add build assets 2020-03-15 06:31:24 +09:00
peaceiris
6f9a5b7a66 test: skipOnFork() 2020-03-14 21:31:02 +00:00
peaceiris
5c097c0f86 chore(release): Remove build assets [skip ci] 2020-03-15 06:13:31 +09:00
peaceiris
0f6166f02c chore(release): 3.5.4-3 2020-03-15 06:13:31 +09:00
peaceiris
2712ed55b1 chore(release): Add build assets 2020-03-15 06:13:30 +09:00
peaceiris
01976c9d9b fix: skip logic 2020-03-14 21:13:09 +00:00
peaceiris
78a39ce0df chore(release): Remove build assets [skip ci] 2020-03-15 06:03:00 +09:00
peaceiris
90a40adfe5 chore(release): 3.5.4-2 2020-03-15 06:03:00 +09:00
peaceiris
d3e35b292a chore(release): Add build assets 2020-03-15 06:02:59 +09:00
peaceiris
c97a39a35f fix: skip logic 2020-03-14 21:02:35 +00:00
peaceiris
9df954b37b chore(release): Remove build assets [skip ci] 2020-03-15 05:51:59 +09:00
peaceiris
dea6ee7419 chore(release): 3.5.4-1 2020-03-15 05:51:59 +09:00
peaceiris
2ca4395141 chore(release): Add build assets 2020-03-15 05:51:58 +09:00
peaceiris
6546aa9608 fix: isForkRepository 2020-03-14 20:51:26 +00:00
peaceiris
a60eec20ec chore(release): Remove build assets [skip ci] 2020-03-15 05:47:00 +09:00
peaceiris
21536c05d5 chore(release): 3.5.4-0 2020-03-15 05:46:59 +09:00
peaceiris
3a443e3a0a chore(release): Add build assets 2020-03-15 05:46:59 +09:00
peaceiris
c320668126 fix: skip on forks
Close #153
2020-03-14 20:45:50 +00:00
7 changed files with 27085 additions and 4 deletions

View File

@ -2,6 +2,60 @@
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-5](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-4...v3.5.4-5) (2020-03-14)
### fix
* property access ([72f58a0](https://github.com/peaceiris/actions-gh-pages/commit/72f58a06cf5db88d3eb982f57de8dbc266e39232))
## [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)
### fix
* skip logic ([01976c9](https://github.com/peaceiris/actions-gh-pages/commit/01976c9d9b95b42997caa2a85c2d737eb75e852e))
## [3.5.4-2](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-1...v3.5.4-2) (2020-03-14)
### fix
* skip logic ([c97a39a](https://github.com/peaceiris/actions-gh-pages/commit/c97a39a35f681badbf7490c2786eddf06b17316d))
## [3.5.4-1](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-0...v3.5.4-1) (2020-03-14)
### fix
* isForkRepository ([6546aa9](https://github.com/peaceiris/actions-gh-pages/commit/6546aa96085e89bd91adc56f58be665766e93a1e))
## [3.5.4-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.3...v3.5.4-0) (2020-03-14)
### fix
* skip on forks ([c320668](https://github.com/peaceiris/actions-gh-pages/commit/c320668126b104ad2c15ea1b583a75cd3978c2f3)), closes [#153](https://github.com/peaceiris/actions-gh-pages/issues/153)
## [3.5.3](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.2...v3.5.3) (2020-03-13)

View File

@ -5,7 +5,8 @@ import {
getWorkDirName,
createWorkDir,
addNoJekyll,
addCNAME
addCNAME,
skipOnFork
} from '../src/utils';
beforeEach(() => {
@ -203,3 +204,30 @@ describe('addCNAME()', () => {
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();
});
});

26964
lib/index.js Normal file

File diff suppressed because it is too large Load Diff

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "actions-github-pages",
"version": "3.5.3",
"version": "3.5.4-5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "actions-github-pages",
"version": "3.5.3",
"version": "3.5.4-5",
"description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js",
"engines": {

View File

@ -1,16 +1,32 @@
import {context} from '@actions/github';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {Inputs} from './interfaces';
import {showInputs, getInputs} from './get-inputs';
import {setTokens} from './set-tokens';
import {setRepo, setCommitAuthor, commit, push, pushTag} from './git-utils';
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
import {getWorkDirName, addNoJekyll, addCNAME, skipOnFork} from './utils';
export async function run(): Promise<void> {
try {
const inps: Inputs = getInputs();
showInputs(inps);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isForkRepository = (context.payload as any).repository.fork;
const isSkipOnFork = await skipOnFork(
isForkRepository,
inps.GithubToken,
inps.DeployKey,
inps.PersonalToken
);
if (isSkipOnFork) {
core.warning(
'Action runs on fork and deploy_key or personal_token is empty, Skip deployment'
);
return;
}
const remoteURL = await setTokens(inps);
core.debug(`[INFO] remoteURL: ${remoteURL}`);

View File

@ -62,3 +62,22 @@ export async function addCNAME(
fs.writeFileSync(filepath, content + '\n');
core.info(`[INFO] Created ${filepath}`);
}
export async function skipOnFork(
isForkRepository: boolean,
githubToken: string,
deployKey: string,
personalToken: string
): Promise<boolean> {
if (isForkRepository) {
if (githubToken) {
return false;
}
if (deployKey === '' && personalToken === '') {
return true;
}
}
return false;
}