Repository navigation
[No QA] Deploy staging web builds to the staging Static Assets Worker #104104
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
Changes from all commits
96b3cc9
f85b94b
3ca6841
45ae241
0e95c85
e171117
5e6140c
0cb2ad3
011dc3a
fe6e49b
63b7f5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -770,12 +770,17 @@ jobs: | |
| env: | ||
| HOST: ${{ env.DEPLOY_ENV == 'production' && vars.WEB_PRODUCTION_HOST || vars.WEB_STAGING_HOST }} | ||
|
|
||
| webDeployTestStaging: | ||
| name: Deploy Web to test-staging.new.expensify.com | ||
| needs: [prep, webBuild] | ||
| if: ${{ needs.webBuild.result == 'success' && needs.prep.outputs.DEPLOY_ENV == 'staging' }} | ||
| webDeployCloudflareWorkers: | ||
| name: Deploy Web to Cloudflare Workers (${{ matrix.environment }}) | ||
| needs: [prep, webBuild, buildStorybook] | ||
| if: ${{ always() && needs.webBuild.result == 'success' && needs.prep.outputs.DEPLOY_ENV == 'staging' }} | ||
| # Trial hosting for the web build, so a failure here must not fail the staging deploy. | ||
| continue-on-error: true | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # `staging` serves no traffic until staging.new.expensify.com is routed to its Worker in Cloudflare. | ||
| environment: [test-staging, staging] | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| steps: | ||
| - name: Checkout | ||
|
|
@@ -801,19 +806,50 @@ jobs: | |
| - name: Extract web build | ||
| run: tar -xzf "${{ needs.webBuild.outputs.TAR_FILENAME }}" | ||
|
|
||
| # The Workers serve these to tabs still running this build after later deploys. Both Workers read the same bucket, | ||
| # so only one matrix leg uploads. | ||
| - name: Upload web build to the previous builds bucket | ||
| if: ${{ matrix.environment == 'staging' }} | ||
| continue-on-error: true | ||
| run: | | ||
| if [[ -z "$AWS_ACCESS_KEY_ID" ]]; then | ||
| echo "::warning::CLOUDFLARE_R2_WEB_ASSETS_ACCESS_KEY_ID is not set, so this build is not available to future deploys." | ||
| exit 0 | ||
| fi | ||
| aws configure set default.s3.preferred_transfer_client classic | ||
| # Re-uploads every file, so files that stay the same across builds don't hit the bucket's 60-day expiry while still in use. | ||
| aws s3 cp dist s3://new-expensify-web-assets-staging/ --recursive \ | ||
| --endpoint-url "https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com" \ | ||
| --no-progress \ | ||
| --exclude '*.br' --exclude '*.map' | ||
| env: | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_WEB_ASSETS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_WEB_ASSETS_SECRET_ACCESS_KEY }} | ||
| AWS_DEFAULT_REGION: auto | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
|
|
||
| - name: Download storybook docs artifact | ||
| continue-on-error: true | ||
| # v7 | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 | ||
| with: | ||
| name: storybook-docs-artifact | ||
| path: ./dist/docs | ||
|
|
||
| - name: Install Cloudflare Worker dependencies | ||
| working-directory: web/cloudflare-worker | ||
| run: npm ci | ||
|
|
||
| - name: Deploy to Cloudflare Workers | ||
| working-directory: web/cloudflare-worker | ||
| run: npx wrangler deploy --env test-staging | ||
| run: npx wrangler deploy --env "${{ matrix.environment }}" | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_DEPLOY_TOKEN }} | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| WRANGLER_SEND_METRICS: false | ||
|
|
||
| - name: Verify deploy | ||
| if: ${{ matrix.environment == 'test-staging' }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why only verify on test-staging?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We aren't mapping the worker to staging here yet, but rather just deploying to it. I'll have to update the route in the console after. The alternative is we manage the route in the wrangler config file here and have this PR act as a staging cutover once it's merged. Maybe that's fine? I guess I'm being overly cautious that someone won't mess with the route hostname and miss it in a review, because that has the potential to cause a site outage with a bad edit.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine to leave things that won't change often and have a high risk of causing outages (e.g. the host name), on a dashboard that only ring0 has access to change. |
||
| run: | | ||
| APP_VERSION=$(jq -r .version < package.json) | ||
| ./.github/scripts/verifyDeploy.sh https://test-staging.new.expensify.com "$APP_VERSION" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the PR can go whenever and we'll make the switch when ready via dashboard