Skip to content

Commit adea226

Browse files
committed
Removes the branch
1 parent dd4a1cd commit adea226

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

__tests__/git.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ describe('git', () => {
341341
const response = await deploy(action)
342342

343343
// Includes the call to generateBranch
344-
expect(execute).toBeCalledTimes(12)
344+
expect(execute).toBeCalledTimes(13)
345345
expect(rmRF).toBeCalledTimes(1)
346346
expect(response).toBe(Status.SUCCESS)
347347
})
@@ -361,7 +361,7 @@ describe('git', () => {
361361
await deploy(action)
362362

363363
// Includes the call to generateBranch
364-
expect(execute).toBeCalledTimes(18)
364+
expect(execute).toBeCalledTimes(19)
365365
expect(rmRF).toBeCalledTimes(1)
366366
})
367367

@@ -382,7 +382,7 @@ describe('git', () => {
382382
await deploy(action)
383383

384384
// Includes the call to generateBranch
385-
expect(execute).toBeCalledTimes(12)
385+
expect(execute).toBeCalledTimes(13)
386386
expect(rmRF).toBeCalledTimes(1)
387387
})
388388

@@ -402,7 +402,7 @@ describe('git', () => {
402402
await deploy(action)
403403

404404
// Includes the call to generateBranch
405-
expect(execute).toBeCalledTimes(12)
405+
expect(execute).toBeCalledTimes(13)
406406
expect(rmRF).toBeCalledTimes(1)
407407
})
408408

@@ -421,7 +421,7 @@ describe('git', () => {
421421

422422
await deploy(action)
423423

424-
expect(execute).toBeCalledTimes(12)
424+
expect(execute).toBeCalledTimes(13)
425425
expect(rmRF).toBeCalledTimes(1)
426426
expect(mkdirP).toBeCalledTimes(1)
427427
})
@@ -439,7 +439,7 @@ describe('git', () => {
439439
})
440440

441441
const response = await deploy(action)
442-
expect(execute).toBeCalledTimes(13)
442+
expect(execute).toBeCalledTimes(14)
443443
expect(rmRF).toBeCalledTimes(1)
444444
expect(response).toBe(Status.SKIPPED)
445445
})
@@ -461,7 +461,7 @@ describe('git', () => {
461461
try {
462462
await deploy(action)
463463
} catch (e) {
464-
expect(execute).toBeCalledTimes(1)
464+
expect(execute).toBeCalledTimes(2)
465465
expect(rmRF).toBeCalledTimes(1)
466466
expect(e.message).toMatch(
467467
'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. ❌'

__tests__/main.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('main', () => {
4747
debug: true
4848
})
4949
await run(action)
50-
expect(execute).toBeCalledTimes(19)
50+
expect(execute).toBeCalledTimes(20)
5151
expect(rmRF).toBeCalledTimes(1)
5252
expect(exportVariable).toBeCalledTimes(1)
5353
})
@@ -64,7 +64,7 @@ describe('main', () => {
6464
}
6565
})
6666
await run(action)
67-
expect(execute).toBeCalledTimes(18)
67+
expect(execute).toBeCalledTimes(19)
6868
expect(rmRF).toBeCalledTimes(1)
6969
expect(exportVariable).toBeCalledTimes(1)
7070
})

src/constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ export const action: ActionInterface = {
6767
? getInput('GIT_CONFIG_EMAIL')
6868
: pusher && pusher.email
6969
? pusher.email
70-
: `${process.env.GITHUB_ACTOR ||
71-
'github-pages-deploy-action'}@users.noreply.github.com`,
70+
: `${
71+
process.env.GITHUB_ACTOR || 'github-pages-deploy-action'
72+
}@users.noreply.github.com`,
7273
gitHubToken: getInput('GITHUB_TOKEN'),
7374
name: !isNullOrUndefined(getInput('GIT_CONFIG_NAME'))
7475
? getInput('GIT_CONFIG_NAME')

src/git.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ export async function deploy(action: ActionInterface): Promise<Status> {
248248
`git worktree remove ${temporaryDeploymentDirectory} --force`,
249249
action.workspace
250250
)
251+
await execute(
252+
`git branch -d ${temporaryDeploymentBranch}`,
253+
action.workspace
254+
)
251255
await rmRF(temporaryDeploymentDirectory)
252256
}
253257
}

src/util.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ export const generateTokenType = (action: ActionInterface): string =>
1919
export const generateRepositoryPath = (action: ActionInterface): string =>
2020
action.ssh
2121
? `git@github.com:${action.repositoryName}`
22-
: `https://${action.accessToken ||
23-
`x-access-token:${action.gitHubToken}`}@github.com/${
24-
action.repositoryName
25-
}.git`
22+
: `https://${
23+
action.accessToken || `x-access-token:${action.gitHubToken}`
24+
}@github.com/${action.repositoryName}.git`
2625

2726
/* Checks for the required tokens and formatting. Throws an error if any case is matched. */
2827
export const hasRequiredParameters = (action: ActionInterface): void => {

0 commit comments

Comments
 (0)