2020-02-05 14:34:19 +09:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
import * as exec from '@actions/exec';
|
|
|
|
import {Inputs} from './interfaces';
|
|
|
|
import {getInputs} from './get-inputs';
|
|
|
|
import {setTokens} from './set-tokens';
|
|
|
|
import * as git from './git-utils';
|
2020-02-24 18:49:55 +09:00
|
|
|
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
|
2020-02-05 14:34:19 +09:00
|
|
|
|
|
|
|
export async function run(): Promise<void> {
|
|
|
|
try {
|
|
|
|
const inps: Inputs = getInputs();
|
|
|
|
|
|
|
|
await git.setConfig(inps.UserName, inps.UserEmail);
|
|
|
|
|
|
|
|
const remoteURL = await setTokens(inps);
|
2020-02-05 18:50:44 +09:00
|
|
|
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
2020-02-05 14:34:19 +09:00
|
|
|
|
2020-02-19 22:56:40 +09:00
|
|
|
const date = new Date();
|
|
|
|
const unixTime = date.getTime();
|
2020-02-24 18:49:55 +09:00
|
|
|
const workDir = await getWorkDirName(`${unixTime}`);
|
|
|
|
await git.setRepo(inps, remoteURL, workDir);
|
|
|
|
|
|
|
|
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
|
|
|
await addCNAME(workDir, inps.CNAME);
|
2020-02-05 14:34:19 +09:00
|
|
|
|
|
|
|
try {
|
|
|
|
await exec.exec('git', ['remote', 'rm', 'origin']);
|
|
|
|
} catch (e) {
|
2020-02-24 18:49:55 +09:00
|
|
|
core.info(`[INFO] ${e}`);
|
2020-02-05 14:34:19 +09:00
|
|
|
}
|
|
|
|
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
|
|
|
await exec.exec('git', ['add', '--all']);
|
|
|
|
|
|
|
|
await git.commit(
|
|
|
|
inps.AllowEmptyCommit,
|
|
|
|
inps.ExternalRepository,
|
|
|
|
inps.CommitMessage
|
|
|
|
);
|
|
|
|
await git.push(inps.PublishBranch, inps.ForceOrphan);
|
|
|
|
await git.pushTag(inps.TagName, inps.TagMessage);
|
2020-02-19 22:56:40 +09:00
|
|
|
|
2020-02-08 17:31:09 +09:00
|
|
|
core.info('[INFO] Action successfully completed');
|
2020-02-05 14:34:19 +09:00
|
|
|
|
|
|
|
return;
|
|
|
|
} catch (e) {
|
|
|
|
throw new Error(e);
|
|
|
|
}
|
|
|
|
}
|