Removes the worktree (#309)

* Removes the worktree

* Tests
This commit is contained in:
James Ives 2020-05-24 10:57:49 -04:00 committed by GitHub
parent ebb288ab72
commit 0657078fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

View File

@ -341,7 +341,7 @@ describe('git', () => {
const response = await deploy(action) const response = await deploy(action)
// Includes the call to generateBranch // Includes the call to generateBranch
expect(execute).toBeCalledTimes(11) expect(execute).toBeCalledTimes(12)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
expect(response).toBe(Status.SUCCESS) expect(response).toBe(Status.SUCCESS)
}) })
@ -361,7 +361,7 @@ describe('git', () => {
await deploy(action) await deploy(action)
// Includes the call to generateBranch // Includes the call to generateBranch
expect(execute).toBeCalledTimes(17) expect(execute).toBeCalledTimes(18)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
}) })
@ -382,7 +382,7 @@ describe('git', () => {
await deploy(action) await deploy(action)
// Includes the call to generateBranch // Includes the call to generateBranch
expect(execute).toBeCalledTimes(11) expect(execute).toBeCalledTimes(12)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
}) })
@ -402,7 +402,7 @@ describe('git', () => {
await deploy(action) await deploy(action)
// Includes the call to generateBranch // Includes the call to generateBranch
expect(execute).toBeCalledTimes(11) expect(execute).toBeCalledTimes(12)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
}) })
@ -421,7 +421,7 @@ describe('git', () => {
await deploy(action) await deploy(action)
expect(execute).toBeCalledTimes(11) expect(execute).toBeCalledTimes(12)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
expect(mkdirP).toBeCalledTimes(1) expect(mkdirP).toBeCalledTimes(1)
}) })
@ -439,7 +439,7 @@ describe('git', () => {
}) })
const response = await deploy(action) const response = await deploy(action)
expect(execute).toBeCalledTimes(12) expect(execute).toBeCalledTimes(13)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
expect(response).toBe(Status.SKIPPED) expect(response).toBe(Status.SKIPPED)
}) })
@ -461,7 +461,7 @@ describe('git', () => {
try { try {
await deploy(action) await deploy(action)
} catch (e) { } catch (e) {
expect(execute).toBeCalledTimes(0) expect(execute).toBeCalledTimes(1)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
expect(e.message).toMatch( expect(e.message).toMatch(
'The deploy step encountered an error: No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true. ❌' 'The deploy step encountered an error: No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true. ❌'

View File

@ -47,7 +47,7 @@ describe('main', () => {
debug: true debug: true
}) })
await run(action) await run(action)
expect(execute).toBeCalledTimes(18) expect(execute).toBeCalledTimes(19)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
expect(exportVariable).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1)
}) })
@ -64,7 +64,7 @@ describe('main', () => {
} }
}) })
await run(action) await run(action)
expect(execute).toBeCalledTimes(17) expect(execute).toBeCalledTimes(18)
expect(rmRF).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1)
expect(exportVariable).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1)
}) })

View File

@ -246,6 +246,10 @@ export async function deploy(action: ActionInterface): Promise<Status> {
) )
} finally { } finally {
// Ensures the deployment directory is safely removed after each deployment. // Ensures the deployment directory is safely removed after each deployment.
await execute(
`git worktree remove ${temporaryDeploymentDirectory}`,
action.workspace
)
await rmRF(temporaryDeploymentDirectory) await rmRF(temporaryDeploymentDirectory)
} }
} }