From 5ba5849ab229d5b6eecc1d13de82e71999961cdc Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Wed, 19 Feb 2020 01:26:00 +0900 Subject: [PATCH] fix: Add removing workDir at the end --- src/git-utils.ts | 11 +++++++---- src/main.ts | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/git-utils.ts b/src/git-utils.ts index 654bdd75f..8022c97c9 100644 --- a/src/git-utils.ts +++ b/src/git-utils.ts @@ -38,7 +38,10 @@ export async function copyAssets( return; } -export async function setRepo(inps: Inputs, remoteURL: string): Promise { +export async function setRepo( + inps: Inputs, + remoteURL: string +): Promise { const workDir = path.join(getHomeDir(), 'actions_github_pages'); const publishDir = path.join( `${process.env.GITHUB_WORKSPACE}`, @@ -51,7 +54,7 @@ export async function setRepo(inps: Inputs, remoteURL: string): Promise { process.chdir(workDir); await createBranchForce(inps.PublishBranch); await copyAssets(publishDir, workDir); - return; + return workDir; } const result: CmdResult = { @@ -89,7 +92,7 @@ export async function setRepo(inps: Inputs, remoteURL: string): Promise { } await copyAssets(publishDir, workDir); - return; + return workDir; } else { throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`); } @@ -102,7 +105,7 @@ export async function setRepo(inps: Inputs, remoteURL: string): Promise { process.chdir(workDir); await createBranchForce(inps.PublishBranch); await copyAssets(publishDir, workDir); - return; + return workDir; } } diff --git a/src/main.ts b/src/main.ts index edc6b19b6..c17796868 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; +import * as io from '@actions/io'; import {Inputs} from './interfaces'; import {getInputs} from './get-inputs'; import {setTokens} from './set-tokens'; @@ -14,7 +15,7 @@ export async function run(): Promise { const remoteURL = await setTokens(inps); core.debug(`[INFO] remoteURL: ${remoteURL}`); - await git.setRepo(inps, remoteURL); + const workDir = await git.setRepo(inps, remoteURL); try { await exec.exec('git', ['remote', 'rm', 'origin']); @@ -33,6 +34,8 @@ export async function run(): Promise { await git.pushTag(inps.TagName, inps.TagMessage); core.info('[INFO] Action successfully completed'); + io.rmRF(workDir); + return; } catch (e) { throw new Error(e);