Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21536c05d5 | ||
|
|
3a443e3a0a | ||
|
|
c320668126 | ||
|
|
ff31e77830 |
@@ -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.
|
||||
|
||||
## [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)
|
||||
|
||||
|
||||
|
||||
18
lib/index.js
18
lib/index.js
@@ -2258,6 +2258,10 @@ function run() {
|
||||
try {
|
||||
const inps = get_inputs_1.getInputs();
|
||||
get_inputs_1.showInputs(inps);
|
||||
const isSkipOnFork = yield utils_1.skipOnFork(inps.GithubToken, inps.DeployKey, inps.PersonalToken);
|
||||
if (isSkipOnFork) {
|
||||
return;
|
||||
}
|
||||
const remoteURL = yield set_tokens_1.setTokens(inps);
|
||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||
const date = new Date();
|
||||
@@ -2690,6 +2694,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const github_1 = __webpack_require__(469);
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const path_1 = __importDefault(__webpack_require__(622));
|
||||
@@ -2755,6 +2760,19 @@ function addCNAME(workDir, content) {
|
||||
});
|
||||
}
|
||||
exports.addCNAME = addCNAME;
|
||||
function skipOnFork(githubToken, deployKey, personalToken) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const isForkRepository = github_1.context.payload.repository.fork.toUpperCase() === 'TRUE';
|
||||
if (!isForkRepository || githubToken) {
|
||||
return false;
|
||||
}
|
||||
if (isForkRepository && (deployKey || personalToken)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
exports.skipOnFork = skipOnFork;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "actions-github-pages",
|
||||
"version": "3.5.3",
|
||||
"version": "3.5.4-0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "actions-github-pages",
|
||||
"version": "3.5.3",
|
||||
"version": "3.5.4-0",
|
||||
"description": "GitHub Actions for GitHub Pages",
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
|
||||
11
src/main.ts
11
src/main.ts
@@ -4,13 +4,22 @@ 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);
|
||||
|
||||
const isSkipOnFork = await skipOnFork(
|
||||
inps.GithubToken,
|
||||
inps.DeployKey,
|
||||
inps.PersonalToken
|
||||
);
|
||||
if (isSkipOnFork) {
|
||||
return;
|
||||
}
|
||||
|
||||
const remoteURL = await setTokens(inps);
|
||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||
|
||||
|
||||
21
src/utils.ts
21
src/utils.ts
@@ -1,3 +1,4 @@
|
||||
import {context} from '@actions/github';
|
||||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import path from 'path';
|
||||
@@ -62,3 +63,23 @@ export async function addCNAME(
|
||||
fs.writeFileSync(filepath, content + '\n');
|
||||
core.info(`[INFO] Created ${filepath}`);
|
||||
}
|
||||
|
||||
export async function skipOnFork(
|
||||
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.toUpperCase() === 'TRUE';
|
||||
|
||||
if (!isForkRepository || githubToken) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isForkRepository && (deployKey || personalToken)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user