mirror of
https://github.com/peaceiris/actions-gh-pages.git
synced 2025-07-17 07:54:45 +08:00
fix: use onetime workdir name
This commit is contained in:
parent
00311793aa
commit
0d912a1314
@ -40,9 +40,10 @@ export async function copyAssets(
|
|||||||
|
|
||||||
export async function setRepo(
|
export async function setRepo(
|
||||||
inps: Inputs,
|
inps: Inputs,
|
||||||
remoteURL: string
|
remoteURL: string,
|
||||||
): Promise<string> {
|
unixTime: string
|
||||||
const workDir = path.join(getHomeDir(), 'actions_github_pages');
|
): Promise<void> {
|
||||||
|
const workDir = path.join(getHomeDir(), `actions_github_pages_${unixTime}`);
|
||||||
const publishDir = path.join(
|
const publishDir = path.join(
|
||||||
`${process.env.GITHUB_WORKSPACE}`,
|
`${process.env.GITHUB_WORKSPACE}`,
|
||||||
inps.PublishDir
|
inps.PublishDir
|
||||||
@ -54,7 +55,7 @@ export async function setRepo(
|
|||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
await createBranchForce(inps.PublishBranch);
|
await createBranchForce(inps.PublishBranch);
|
||||||
await copyAssets(publishDir, workDir);
|
await copyAssets(publishDir, workDir);
|
||||||
return workDir;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: CmdResult = {
|
const result: CmdResult = {
|
||||||
@ -92,7 +93,7 @@ export async function setRepo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
await copyAssets(publishDir, workDir);
|
await copyAssets(publishDir, workDir);
|
||||||
return workDir;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
|
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
|
||||||
}
|
}
|
||||||
@ -105,7 +106,7 @@ export async function setRepo(
|
|||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
await createBranchForce(inps.PublishBranch);
|
await createBranchForce(inps.PublishBranch);
|
||||||
await copyAssets(publishDir, workDir);
|
await copyAssets(publishDir, workDir);
|
||||||
return workDir;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
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 * as io from '@actions/io';
|
|
||||||
import {Inputs} from './interfaces';
|
import {Inputs} from './interfaces';
|
||||||
import {getInputs} from './get-inputs';
|
import {getInputs} from './get-inputs';
|
||||||
import {setTokens} from './set-tokens';
|
import {setTokens} from './set-tokens';
|
||||||
@ -15,7 +14,9 @@ export async function run(): Promise<void> {
|
|||||||
const remoteURL = await setTokens(inps);
|
const remoteURL = await setTokens(inps);
|
||||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||||
|
|
||||||
const workDir = await git.setRepo(inps, remoteURL);
|
const date = new Date();
|
||||||
|
const unixTime = date.getTime();
|
||||||
|
await git.setRepo(inps, remoteURL, unixTime);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await exec.exec('git', ['remote', 'rm', 'origin']);
|
await exec.exec('git', ['remote', 'rm', 'origin']);
|
||||||
@ -33,9 +34,6 @@ export async function run(): Promise<void> {
|
|||||||
await git.push(inps.PublishBranch, inps.ForceOrphan);
|
await git.push(inps.PublishBranch, inps.ForceOrphan);
|
||||||
await git.pushTag(inps.TagName, inps.TagMessage);
|
await git.pushTag(inps.TagName, inps.TagMessage);
|
||||||
|
|
||||||
core.info(`[INFO] Deleting ${workDir}`);
|
|
||||||
await io.rmRF(workDir);
|
|
||||||
|
|
||||||
core.info('[INFO] Action successfully completed');
|
core.info('[INFO] Action successfully completed');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user