Skip to content

Commit

Permalink
Merge pull request #43 from axelerant/issue-35
Browse files Browse the repository at this point in the history
handle deleting dirty environments
  • Loading branch information
zeshanziya authored Aug 12, 2024
2 parents df1b8dc + a289545 commit 0d7a9da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions __tests__/clean-pr-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('cleanPrEnv', () => {
})

it('should handle unexpected environment status', async () => {
const mockEnvResult = mockEnvironmentResult('dirty')
const mockEnvResult = mockEnvironmentResult('deleting')
mockClient.getEnvironment.mockResolvedValue(mockEnvResult)
github.context.payload.pull_request = { number: 123 }

Expand All @@ -127,7 +127,7 @@ describe('cleanPrEnv', () => {
expect(mockEnvResult.deactivate).not.toHaveBeenCalled()
expect(mockEnvResult.delete).not.toHaveBeenCalled()
expect(core.warning).toHaveBeenCalledWith(
`Unable to delete 123/merge environment as it's already in dirty mode`
`Unable to delete 123/merge environment as it's already in deleting mode`
)
expect(core.endGroup).toHaveBeenCalled()
})
Expand Down
6 changes: 5 additions & 1 deletion src/clean-pr-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export async function cleanPrEnv(): Promise<void> {
}

// Check the status of the environment.
if (envResult.status === 'active' || envResult.status === 'paused') {
if (
envResult.status === 'active' ||
envResult.status === 'paused' ||
envResult.status === 'dirty'
) {
const activity = await envResult.deactivate()
core.info(`Deactivating ${prRef} environment...`)
// @todo display activity log
Expand Down

0 comments on commit 0d7a9da

Please sign in to comment.