From 8d2e1ad5777705ea13ca0afeee821bdb7abd8516 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Fri, 1 Oct 2021 13:37:46 -0500 Subject: [PATCH] Enable prod deployment via Actions (Take 2!) (#21852) * Move concurrency control to top-level in prod deploy workflow * Add 503 to the list of temporarily acceptable Heroku failure codes * Add HEROKU_PRODUCTION_APP_NAME back into the prod deploy workflow --- .github/workflows/prod-build-deploy.yml | 14 +++++++++++--- script/deployment/deploy-to-production.js | 2 +- script/deployment/deploy-to-staging.js | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/prod-build-deploy.yml b/.github/workflows/prod-build-deploy.yml index 7e5aeec28d..c1483d4ed7 100644 --- a/.github/workflows/prod-build-deploy.yml +++ b/.github/workflows/prod-build-deploy.yml @@ -14,14 +14,15 @@ permissions: contents: read deployments: write +concurrency: + group: '${{ github.workflow }}' + cancel-in-progress: true + jobs: build-and-deploy: if: ${{ github.repository == 'github/docs-internal'}} runs-on: ubuntu-latest timeout-minutes: 15 - concurrency: - group: prod_deploy - cancel-in-progress: true steps: - name: Check out repo uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f @@ -137,6 +138,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }} + HEROKU_PRODUCTION_APP_NAME: ${{ secrets.HEROKU_PRODUCTION_APP_NAME }} HYDRO_ENDPOINT: ${{ secrets.HYDRO_ENDPOINT }} HYDRO_SECRET: ${{ secrets.HYDRO_SECRET }} SOURCE_BLOB_URL: ${{ steps.build-source.outputs.download_url }} @@ -146,6 +148,7 @@ jobs: const { GITHUB_TOKEN, HEROKU_API_TOKEN, + HEROKU_PRODUCTION_APP_NAME, SOURCE_BLOB_URL, DELAY_FOR_PREBOOT } = process.env @@ -160,6 +163,11 @@ jobs: throw new Error('You must supply a HEROKU_API_TOKEN environment variable!') } + // Exit if Heroku App name is not found + if (!HEROKU_PRODUCTION_APP_NAME) { + throw new Error('You must supply a HEROKU_PRODUCTION_APP_NAME environment variable!') + } + // Workaround to allow us to load ESM files with `require(...)` const esm = require('esm') require = esm({}) diff --git a/script/deployment/deploy-to-production.js b/script/deployment/deploy-to-production.js index 970d07454a..408bae4c91 100755 --- a/script/deployment/deploy-to-production.js +++ b/script/deployment/deploy-to-production.js @@ -11,7 +11,7 @@ const DELAY_FOR_PREBOOT_SWAP = 135000 // 2:15 // Allow for a few 404 (Not Found), 429 (Too Many Requests), etc. responses from // the semi-unreliable Heroku API when we're polling for status updates const ALLOWED_MISSING_RESPONSE_COUNT = 5 -const ALLOWABLE_ERROR_CODES = [404, 429, 500] +const ALLOWABLE_ERROR_CODES = [404, 429, 500, 503] export default async function deployToProduction({ octokit, diff --git a/script/deployment/deploy-to-staging.js b/script/deployment/deploy-to-staging.js index 6a0b8f41fe..c1f2b79b86 100644 --- a/script/deployment/deploy-to-staging.js +++ b/script/deployment/deploy-to-staging.js @@ -11,7 +11,7 @@ const HEROKU_LOG_LINES_TO_SHOW = 25 // Allow for a few 404 (Not Found), 429 (Too Many Requests), etc. responses from // the semi-unreliable Heroku API when we're polling for status updates const ALLOWED_MISSING_RESPONSE_COUNT = 5 -const ALLOWABLE_ERROR_CODES = [404, 429, 500] +const ALLOWABLE_ERROR_CODES = [404, 429, 500, 503] export default async function deployToStaging({ octokit,