Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Use loop to verify web deploy #49862

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading