fix prune preview deployment script (#2698)
The script that prunes old preview deployments in cloudlfare was broken when we moved dotcom into the public repo. This fixes it. ### Change Type - [x] `internal` — Any other changes that don't affect the published package[^2]
This commit is contained in:
parent
45c8777ea0
commit
9ca5d5f22d
2 changed files with 19 additions and 7 deletions
2
.github/workflows/prune-preview-deploys.yml
vendored
2
.github/workflows/prune-preview-deploys.yml
vendored
|
@ -16,7 +16,7 @@ jobs:
|
|||
deploy:
|
||||
name: Prune preview deploys
|
||||
timeout-minutes: 15
|
||||
runs-on: ubuntu-latest-16-cores
|
||||
runs-on: ubuntu-latest-16-cores-open
|
||||
environment: deploy-staging
|
||||
|
||||
steps:
|
||||
|
|
|
@ -16,11 +16,21 @@ async function isPrClosedForAWhile(prNumber: number) {
|
|||
if (_isPrClosedCache.has(prNumber)) {
|
||||
return _isPrClosedCache.get(prNumber)!
|
||||
}
|
||||
const prResult = await github.getOctokit(env.GH_TOKEN).rest.pulls.get({
|
||||
|
||||
let prResult
|
||||
try {
|
||||
prResult = await github.getOctokit(env.GH_TOKEN).rest.pulls.get({
|
||||
owner: 'tldraw',
|
||||
repo: 'tldraw',
|
||||
pull_number: prNumber,
|
||||
})
|
||||
} catch (err: any) {
|
||||
if (err.status === 404) {
|
||||
_isPrClosedCache.set(prNumber, true)
|
||||
return true
|
||||
}
|
||||
throw err
|
||||
}
|
||||
const twoDays = 1000 * 60 * 60 * 24 * 2
|
||||
const result =
|
||||
prResult.data.state === 'closed' &&
|
||||
|
@ -62,7 +72,7 @@ async function deletePreviewWorkerDeployment(id: string) {
|
|||
)
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to delete worker ' + JSON.stringify(res))
|
||||
throw new Error('Failed to delete worker ' + JSON.stringify(await res.json()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,6 +87,8 @@ async function main() {
|
|||
nicelog(`Skipping ${deployment} because PR is still open`)
|
||||
}
|
||||
}
|
||||
|
||||
nicelog('Done')
|
||||
}
|
||||
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue