diff --git a/script/deployment/deploy-to-staging.js b/script/deployment/deploy-to-staging.js index 91e11352ea..209f072715 100644 --- a/script/deployment/deploy-to-staging.js +++ b/script/deployment/deploy-to-staging.js @@ -224,7 +224,7 @@ export default async function deployToStaging({ // A new Build is created as a by-product of creating an AppSetup. // Poll until there is a Build object attached to the AppSetup. let setupAcceptableErrorCount = 0 - while (!build || !build.id) { + while (!appSetup || appSetup.status === 'pending' || !build || !build.id) { await sleep(SLEEP_INTERVAL) try { appSetup = await heroku.get(`/app-setups/${appSetup.id}`) @@ -240,6 +240,14 @@ export default async function deployToStaging({ throw new Error(`Failed to get AppSetup status. Error: ${error}`) } + if (appSetup && appSetup.status === 'failed') { + throw new Error( + `Failed to setup app after ${Math.round( + (Date.now() - appSetupStartTime) / 1000 + )} seconds. See Heroku logs for more information:\n${logUrl}` + ) + } + console.log( `AppSetup status: ${appSetup.status} (after ${Math.round( (Date.now() - appSetupStartTime) / 1000 @@ -304,6 +312,15 @@ export default async function deployToStaging({ } throw new Error(`Failed to get build status. Error: ${error}`) } + + if (build && build.status === 'failed') { + throw new Error( + `Failed to build after ${Math.round( + (Date.now() - buildStartTime) / 1000 + )} seconds. See Heroku logs for more information:\n${logUrl}` + ) + } + console.log( `Heroku build status: ${(build || {}).status} (after ${Math.round( (Date.now() - buildStartTime) / 1000 @@ -311,14 +328,6 @@ export default async function deployToStaging({ ) } - if (build.status !== 'succeeded') { - throw new Error( - `Failed to build after ${Math.round( - (Date.now() - buildStartTime) / 1000 - )} seconds. See Heroku logs for more information:\n${logUrl}` - ) - } - console.log( `Finished Heroku build after ${Math.round((Date.now() - buildStartTime) / 1000)} seconds.`, build @@ -356,6 +365,14 @@ export default async function deployToStaging({ throw new Error(`Failed to get release status. Error: ${error}`) } + if (release && release.status === 'failed') { + throw new Error( + `Failed to release after ${Math.round( + (Date.now() - releaseStartTime) / 1000 + )} seconds. See Heroku logs for more information:\n${logUrl}` + ) + } + console.log( `Release status: ${(release || {}).status} (after ${Math.round( (Date.now() - releaseStartTime) / 1000 @@ -363,14 +380,6 @@ export default async function deployToStaging({ ) } - if (release.status !== 'succeeded') { - throw new Error( - `Failed to release after ${Math.round( - (Date.now() - releaseStartTime) / 1000 - )} seconds. See Heroku logs for more information:\n${logUrl}` - ) - } - console.log( `Finished Heroku release after ${Math.round( (Date.now() - releaseStartTime) / 1000