From ef93443abe08fb49bcee436e4a25ce2e42d291c4 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 25 Jul 2024 09:53:05 -0700 Subject: [PATCH 1/5] Add verification for prod web deploy --- .github/workflows/platformDeploy.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index ee8685d27cb7..1bb311660bf1 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -353,6 +353,15 @@ jobs: env: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} + - name: Verify that the deployed version matches what we expect + run: | + LOCAL_VERSION="$(npm run print-version --silent)" + DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://${{ env.SHOULD_DEPLOY_PRODUCTION != 'true' && 'staging.' || '' }}new.expensify.com | jq -r '.version')" + if [[ "$LOCAL_VERSION" != "$DOWNLOADED_VERSION" ]]; then + echo "Error: deployed version does not match local version. Something went wrong..." + exit 1 + fi + postSlackMessageOnFailure: name: Post a Slack message when any platform fails to build or deploy runs-on: ubuntu-latest From c89215beb111b533fbd3ab03802f10c8af0e6e31 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 25 Jul 2024 10:23:38 -0700 Subject: [PATCH 2/5] Use tag name and split up staging and prod --- .github/workflows/platformDeploy.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 1bb311660bf1..bc286baf28ea 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -353,11 +353,20 @@ jobs: env: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} - - name: Verify that the deployed version matches what we expect + - name: Verify staging deploy + if: env.SHOULD_DEPLOY_PRODUCTION != 'true' run: | - LOCAL_VERSION="$(npm run print-version --silent)" - DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://${{ env.SHOULD_DEPLOY_PRODUCTION != 'true' && 'staging.' || '' }}new.expensify.com | jq -r '.version')" - if [[ "$LOCAL_VERSION" != "$DOWNLOADED_VERSION" ]]; then + DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://staging.new.expensify.com | jq -r '.version')" + if [[ '${{ github.ref_name }}' != "$DOWNLOADED_VERSION" ]]; then + echo "Error: deployed version does not match local version. Something went wrong..." + exit 1 + fi + + - name: Verify production deploy + if: env.SHOULD_DEPLOY_PRODUCTION == 'true' + run: | + DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://new.expensify.com | jq -r '.version')" + if [[ '${{ github.event.release.tag_name }}' != "$DOWNLOADED_VERSION" ]]; then echo "Error: deployed version does not match local version. Something went wrong..." exit 1 fi From d898d39157a09c2c68a2773adb9347b362e8e72d Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 25 Jul 2024 10:38:43 -0700 Subject: [PATCH 3/5] Update mocks --- workflow_tests/mocks/platformDeployMocks.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workflow_tests/mocks/platformDeployMocks.ts b/workflow_tests/mocks/platformDeployMocks.ts index 8889e9dc27db..172445dd08f0 100644 --- a/workflow_tests/mocks/platformDeployMocks.ts +++ b/workflow_tests/mocks/platformDeployMocks.ts @@ -181,6 +181,8 @@ const PLATFORM_DEPLOY__WEB__BUILD__STEP_MOCK = createMockStep('Build web', 'Buil const PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS__STEP_MOCK = createMockStep('Build storybook docs', 'Build storybook docs', 'WEB'); const PLATFORM_DEPLOY__WEB__DEPLOY_S3__STEP_MOCK = createMockStep('Deploy to S3', 'Deploying to S3', 'WEB'); const PLATFORM_DEPLOY__WEB__PURGE_CLOUDFLARE_CACHE__STEP_MOCK = createMockStep('Purge Cloudflare cache', 'Purging Cloudflare cache', 'WEB', null, ['CF_API_KEY']); +const PLATFORM_DEPLOY__WEB__VERIFY_STAGING_DEPLOY = createMockStep('Verify staging deploy', 'Verifying staging deploy', 'WEB'); +const PLATFORM_DEPLOY__WEB__VERIFY_PROD_DEPLOY = createMockStep('Verify production deploy', 'Verifying production deploy', 'WEB'); const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK, PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK, @@ -190,6 +192,8 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS__STEP_MOCK, PLATFORM_DEPLOY__WEB__DEPLOY_S3__STEP_MOCK, PLATFORM_DEPLOY__WEB__PURGE_CLOUDFLARE_CACHE__STEP_MOCK, + PLATFORM_DEPLOY__WEB__VERIFY_STAGING_DEPLOY, + PLATFORM_DEPLOY__WEB__VERIFY_PROD_DEPLOY, ]; // post slack message on failure From 8b9edf4a73774bbf3ba54871ad84ed08dc38f67e Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 25 Jul 2024 14:13:31 -0700 Subject: [PATCH 4/5] Use fromJSON --- .github/workflows/platformDeploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index bc286baf28ea..3d79f6eadeec 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -354,7 +354,7 @@ jobs: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} - name: Verify staging deploy - if: env.SHOULD_DEPLOY_PRODUCTION != 'true' + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: | DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://staging.new.expensify.com | jq -r '.version')" if [[ '${{ github.ref_name }}' != "$DOWNLOADED_VERSION" ]]; then @@ -363,7 +363,7 @@ jobs: fi - name: Verify production deploy - if: env.SHOULD_DEPLOY_PRODUCTION == 'true' + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: | DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://new.expensify.com | jq -r '.version')" if [[ '${{ github.event.release.tag_name }}' != "$DOWNLOADED_VERSION" ]]; then From 30af8e4100583d569d21643e625a22559e472b0d Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 25 Jul 2024 14:14:12 -0700 Subject: [PATCH 5/5] Fix download URL --- .github/workflows/platformDeploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 3d79f6eadeec..427ed80a4f97 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -356,7 +356,7 @@ jobs: - name: Verify staging deploy if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: | - DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://staging.new.expensify.com | jq -r '.version')" + DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://staging.new.expensify.com/version.json | jq -r '.version')" if [[ '${{ github.ref_name }}' != "$DOWNLOADED_VERSION" ]]; then echo "Error: deployed version does not match local version. Something went wrong..." exit 1 @@ -365,7 +365,7 @@ jobs: - name: Verify production deploy if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: | - DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://new.expensify.com | jq -r '.version')" + DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://new.expensify.com/version.json | jq -r '.version')" if [[ '${{ github.event.release.tag_name }}' != "$DOWNLOADED_VERSION" ]]; then echo "Error: deployed version does not match local version. Something went wrong..." exit 1