Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

v2023.10.03

v2023.10.03 #145

Workflow file for this run

# Runs Cypress tests locally, deploys the doc site to an S3 bucket and runs post deployment cypress tests again
name: Publish Docsite
on:
release:
types:
- published
workflow_dispatch:
jobs:
cypress:
name: Cypress Tests
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
options: --user 1001 --shm-size=2g
strategy:
fail-fast: false
matrix:
node-version: [16, 18, 20.5.1]
browser: [chrome]
exclude:
- node-version: 16
browser: firefox
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run
uses: cypress-io/[email protected]
timeout-minutes: 20
with:
browser: ${{ matrix.browser }}
start: yarn start
wait-on: http://localhost:3000
wait-on-timeout: 180
working-directory: ./site
config-file: cypress.config.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_ANALYTICS_TRACKING_ID: "12345"
GTAG_TRACKING_ID: "12345"
publish:
name: Publish Docsite
needs: cypress
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Generate Static Site
run: |
cd site
yarn install --pure-lockfile
npm run build
env:
GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.GOOGLE_ANALYTICS_TRACKING_ID }}
GTAG_TRACKING_ID: ${{ secrets. GTAG_TRACKING_ID}}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Sync zip to Bucket
run: |
aws s3 sync ./site/build s3://$BUCKET_NAME --acl public-read --delete
env:
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
- name: Invalidate Cloudfront Cache
id: invalidate1
continue-on-error: true
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID}} --paths "/" "/*"
- name: Invalidate Cloudfront Cache Attempt 2
id: invalidate2
if: steps.invalidate1.outcome=='failure'
continue-on-error: true
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID}} --paths "/" "/*"
- name: Invalidate Cloudfront Cache Attempt 3
continue-on-error: true
id: invalidate3
if: steps.invalidate2.outcome=='failure'
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID}} --paths "/" "/*"
- name: Cloudfront Cache Invalidation Status
if: always()
run: |
if ${{ steps.invalidate1.outcome=='success' || steps.invalidate2.outcome=='success' || steps.invalidate3.outcome=='success' }}; then
echo invalidation successful
else
exit 1
fi
cypress_post_tests:
name: Cypress run on prod
needs: [cypress, publish]
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
options: --user 1001 --shm-size=2g
strategy:
fail-fast: false
matrix:
node-version: [16, 18, 20.5.1]
browser: [chrome]
exclude:
- node-version: 16
browser: firefox
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Checkout
uses: actions/checkout@v3
- name: Cypress Post Deployment Test
uses: cypress-io/[email protected]
timeout-minutes: 20
with:
browser: ${{ matrix.browser }}
working-directory: ./site
config-file: prod-cypress.config.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_ANALYTICS_TRACKING_ID: "12345"
GTAG_TRACKING_ID: "12345"
notify_for_failures:
name: Notify for Failures
needs: [cypress_post_tests]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Notify Slack of Failures
uses: Bandwidth/[email protected]
with:
job-status: failure
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL }}
rollback_if_failed:
needs: [cypress, publish, cypress_post_tests]
name: Rollback Release
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: |
cd ./.github/actions/rollback_release
npm install
- name: Rollback For Failed Cypress Tests
id: rollback
uses: ./.github/actions/rollback_release
env:
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}