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]
pull/2699/head
alex 2024-01-31 16:37:51 +00:00 zatwierdzone przez GitHub
rodzic 45c8777ea0
commit 9ca5d5f22d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 19 dodań i 7 usunięć

Wyświetl plik

@ -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:

Wyświetl plik

@ -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({
owner: 'tldraw',
repo: 'tldraw',
pull_number: prNumber,
})
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()