Skip to content

Commit

Permalink
Merge pull request #49862 from Expensify/Rory-ImproveDeployConfirmation
Browse files Browse the repository at this point in the history
[No QA] Use loop to verify web deploy
  • Loading branch information
AndrewGable authored Sep 27, 2024
2 parents b6b559d + 2ccaacc commit 5ff4975
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/verifyDeploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

ENV="$1"
EXPECTED_VERSION="$2"

BASE_URL=""
if [[ "$ENV" == 'staging' ]]; then
BASE_URL='https://staging.new.expensify.com'
else
BASE_URL='https://new.expensify.com'
fi

sleep 5
ATTEMPT=0
MAX_ATTEMPTS=10
while [[ $ATTEMPT -lt $MAX_ATTEMPTS ]]; do
((ATTEMPT++))

echo "Attempt $ATTEMPT: Checking deployed version..."
DOWNLOADED_VERSION="$(wget -q -O /dev/stdout "$BASE_URL"/version.json | jq -r '.version')"

if [[ "$EXPECTED_VERSION" == "$DOWNLOADED_VERSION" ]]; then
echo "Success: Deployed version matches local version: $DOWNLOADED_VERSION"
exit 0
fi

if [[ $ATTEMPT -lt $MAX_ATTEMPTS ]]; then
echo "Version mismatch, found $DOWNLOADED_VERSION. Retrying in 5 seconds..."
sleep 5
fi
done

echo "Error: Deployed version did not match local version after $MAX_ATTEMPTS attempts. Something went wrong..."
exit 1
16 changes: 2 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,23 +386,11 @@ jobs:

- name: Verify staging deploy
if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}
run: |
sleep 5
DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://staging.new.expensify.com/version.json | jq -r '.version')"
if [[ '${{ needs.prep.outputs.APP_VERSION }}' != "$DOWNLOADED_VERSION" ]]; then
echo "Error: deployed version $DOWNLOADED_VERSION does not match local version ${{ needs.prep.outputs.APP_VERSION }}. Something went wrong..."
exit 1
fi
run: ./.github/scripts/verifyDeploy.sh staging ${{ needs.prep.outputs.APP_VERSION }}

- name: Verify production deploy
if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}
run: |
sleep 5
DOWNLOADED_VERSION="$(wget -q -O /dev/stdout https://new.expensify.com/version.json | jq -r '.version')"
if [[ '${{ needs.prep.outputs.APP_VERSION }}' != "$DOWNLOADED_VERSION" ]]; then
echo "Error: deployed version $DOWNLOADED_VERSION does not match local version ${{ needs.prep.outputs.APP_VERSION }}. Something went wrong..."
exit 1
fi
run: ./.github/scripts/verifyDeploy.sh production ${{ needs.prep.outputs.APP_VERSION }}

- name: Upload web sourcemaps artifact
uses: actions/upload-artifact@v4
Expand Down

0 comments on commit 5ff4975

Please sign in to comment.