From ada1dedf261acffca6461de8c9d64e6bc5f5203b Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Fri, 31 Mar 2023 13:34:01 -0400 Subject: [PATCH] Fail if the preview URL ultimately fails (#36077) --- .github/workflows/azure-preview-env-deploy.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/azure-preview-env-deploy.yml b/.github/workflows/azure-preview-env-deploy.yml index 18d74a74d2..6b8b322b36 100644 --- a/.github/workflows/azure-preview-env-deploy.yml +++ b/.github/workflows/azure-preview-env-deploy.yml @@ -47,9 +47,9 @@ jobs: # See https://bit.ly/3qB9nZW > If a job in a workflow is skipped due to a conditional, it will report its status as "Success". if: | ( - (github.event.pull_request.head.sha || github.event.inputs.COMMIT_REF) + (github.event.pull_request.head.sha || github.event.inputs.COMMIT_REF) && (github.event.number || github.event.inputs.PR_NUMBER || github.run_id) - ) + ) && (github.repository == 'github/docs-internal' || github.repository == 'github/docs') && github.actor != 'dependabot[bot]' timeout-minutes: 15 @@ -213,7 +213,7 @@ jobs: dockerRegistryUsername="${{ env.NONPROD_REGISTRY_USERNAME }}" dockerRegistryPassword="${{ secrets.NONPROD_REGISTRY_PASSWORD }}" - - name: Check that it can reached + - name: Check that it can be reached # This introduces a necessary delay. Because the preview evironment # URL is announced to the pull request as soon as all the steps # finish, what sometimes happens is that a viewer of the PR clicks @@ -223,4 +223,8 @@ jobs: # process requests. # By introducing a slight "delay" here we avoid announcing a # preview environment URL that isn't actually working just yet. - run: curl --retry-connrefused --retry 5 -I ${{ env.APP_URL }} + # Note the use of `--fail`. It which means that if it actually + # did connect but the error code was >=400, the command will fail. + # The `--fail --retry N` combination means that a 4xx response + # code will exit immediately but a 5xx will exhaust the retries. + run: curl --fail --retry-connrefused --retry 5 -I ${{ env.APP_URL }}