Skip to content

Commit 0d912a1

Browse files
committed
fix: use onetime workdir name
1 parent 0031179 commit 0d912a1

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/git-utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ export async function copyAssets(
4040

4141
export async function setRepo(
4242
inps: Inputs,
43-
remoteURL: string
44-
): Promise<string> {
45-
const workDir = path.join(getHomeDir(), 'actions_github_pages');
43+
remoteURL: string,
44+
unixTime: string
45+
): Promise<void> {
46+
const workDir = path.join(getHomeDir(), `actions_github_pages_${unixTime}`);
4647
const publishDir = path.join(
4748
`${process.env.GITHUB_WORKSPACE}`,
4849
inps.PublishDir
@@ -54,7 +55,7 @@ export async function setRepo(
5455
process.chdir(workDir);
5556
await createBranchForce(inps.PublishBranch);
5657
await copyAssets(publishDir, workDir);
57-
return workDir;
58+
return;
5859
}
5960

6061
const result: CmdResult = {
@@ -92,7 +93,7 @@ export async function setRepo(
9293
}
9394

9495
await copyAssets(publishDir, workDir);
95-
return workDir;
96+
return;
9697
} else {
9798
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
9899
}
@@ -105,7 +106,7 @@ export async function setRepo(
105106
process.chdir(workDir);
106107
await createBranchForce(inps.PublishBranch);
107108
await copyAssets(publishDir, workDir);
108-
return workDir;
109+
return;
109110
}
110111
}
111112

src/main.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as core from '@actions/core';
22
import * as exec from '@actions/exec';
3-
import * as io from '@actions/io';
43
import {Inputs} from './interfaces';
54
import {getInputs} from './get-inputs';
65
import {setTokens} from './set-tokens';
@@ -15,7 +14,9 @@ export async function run(): Promise<void> {
1514
const remoteURL = await setTokens(inps);
1615
core.debug(`[INFO] remoteURL: ${remoteURL}`);
1716

18-
const workDir = await git.setRepo(inps, remoteURL);
17+
const date = new Date();
18+
const unixTime = date.getTime();
19+
await git.setRepo(inps, remoteURL, unixTime);
1920

2021
try {
2122
await exec.exec('git', ['remote', 'rm', 'origin']);
@@ -33,9 +34,6 @@ export async function run(): Promise<void> {
3334
await git.push(inps.PublishBranch, inps.ForceOrphan);
3435
await git.pushTag(inps.TagName, inps.TagMessage);
3536

36-
core.info(`[INFO] Deleting ${workDir}`);
37-
await io.rmRF(workDir);
38-
3937
core.info('[INFO] Action successfully completed');
4038

4139
return;

0 commit comments

Comments
 (0)