mirror of
https://github.com/peaceiris/actions-gh-pages.git
synced 2025-07-15 22:56:54 +08:00
fix: Add removing workDir at the end
This commit is contained in:
parent
1c50baa294
commit
5ba5849ab2
@ -38,7 +38,10 @@ export async function copyAssets(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setRepo(inps: Inputs, remoteURL: string): Promise<void> {
|
export async function setRepo(
|
||||||
|
inps: Inputs,
|
||||||
|
remoteURL: string
|
||||||
|
): Promise<string> {
|
||||||
const workDir = path.join(getHomeDir(), 'actions_github_pages');
|
const workDir = path.join(getHomeDir(), 'actions_github_pages');
|
||||||
const publishDir = path.join(
|
const publishDir = path.join(
|
||||||
`${process.env.GITHUB_WORKSPACE}`,
|
`${process.env.GITHUB_WORKSPACE}`,
|
||||||
@ -51,7 +54,7 @@ export async function setRepo(inps: Inputs, remoteURL: string): Promise<void> {
|
|||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
await createBranchForce(inps.PublishBranch);
|
await createBranchForce(inps.PublishBranch);
|
||||||
await copyAssets(publishDir, workDir);
|
await copyAssets(publishDir, workDir);
|
||||||
return;
|
return workDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: CmdResult = {
|
const result: CmdResult = {
|
||||||
@ -89,7 +92,7 @@ export async function setRepo(inps: Inputs, remoteURL: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await copyAssets(publishDir, workDir);
|
await copyAssets(publishDir, workDir);
|
||||||
return;
|
return workDir;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
|
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
|
||||||
}
|
}
|
||||||
@ -102,7 +105,7 @@ export async function setRepo(inps: Inputs, remoteURL: string): Promise<void> {
|
|||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
await createBranchForce(inps.PublishBranch);
|
await createBranchForce(inps.PublishBranch);
|
||||||
await copyAssets(publishDir, workDir);
|
await copyAssets(publishDir, workDir);
|
||||||
return;
|
return workDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
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';
|
||||||
@ -14,7 +15,7 @@ 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}`);
|
||||||
|
|
||||||
await git.setRepo(inps, remoteURL);
|
const workDir = await git.setRepo(inps, remoteURL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await exec.exec('git', ['remote', 'rm', 'origin']);
|
await exec.exec('git', ['remote', 'rm', 'origin']);
|
||||||
@ -33,6 +34,8 @@ export async function run(): Promise<void> {
|
|||||||
await git.pushTag(inps.TagName, inps.TagMessage);
|
await git.pushTag(inps.TagName, inps.TagMessage);
|
||||||
core.info('[INFO] Action successfully completed');
|
core.info('[INFO] Action successfully completed');
|
||||||
|
|
||||||
|
io.rmRF(workDir);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e);
|
throw new Error(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user