Skip to content

Commit

Permalink
Merge pull request #26 from axelerant/issue-22
Browse files Browse the repository at this point in the history
fix for Issue 22
  • Loading branch information
zeshanziya authored Jun 18, 2024
2 parents eb73241 + a7d27f7 commit faa3d1a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/clean-pr-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,27 @@ export async function cleanPrEnv(): Promise<void> {

// Get env details
const prRef = `${prNumber}/merge`
const envResult = await client.getEnvironment(
core.getInput('project-id'),
encodeURIComponent(prRef)
)
let envResult
try {
envResult = await client.getEnvironment(
core.getInput('project-id'),
encodeURIComponent(prRef)
)
} catch (error) {
if (error instanceof Error) {
core.warning(error.message)
}
}

if (!envResult) {
core.warning(`No active environment found for the given PR ${prRef}`)
core.endGroup()
return
}
core.info(`Environment '${envResult.name}' is of type '${envResult.type}'.`)

if (envResult.type !== 'development') {
core.info(
core.warning(
`Not deleting ${prRef} environment as it's not a development environment`
)
core.endGroup()
Expand Down

0 comments on commit faa3d1a

Please sign in to comment.