mirror of
https://github.com/peaceiris/actions-gh-pages.git
synced 2025-07-16 07:03:13 +08:00
parent
ff31e77830
commit
c320668126
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user