Add intentional integration test failure to test rollback step #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy changes | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check-lighthouse-scores: | |
name: Check lighthouse scores | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: npm ci | |
- run: cp .env.ci .env | |
- run: npm run build -- --mode=test | |
- run: npm run lhci -- --upload.token=$LHCI_BUILD_TOKEN | |
env: | |
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} | |
LHCI_BUILD_TOKEN: ${{ secrets.LHCI_BUILD_TOKEN }} | |
run-unit-tests: | |
name: Run unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cypress-io/github-action@v6 | |
with: | |
component: true | |
browser: chrome | |
deploy-to-production: | |
name: Deploy to production | |
runs-on: ubuntu-latest | |
needs: [check-lighthouse-scores, run-unit-tests] | |
environment: production | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: npm ci | |
- run: npm run build | |
env: | |
VITE_PUBLIC_FUNCTIONS_URL: ${{ vars.VITE_PUBLIC_FUNCTIONS_URL }} | |
VITE_PUBLIC_IS_WEB_BUILD: ${{ vars.VITE_PUBLIC_IS_WEB_BUILD }} | |
VITE_PUBLIC_SENTRY_DSN: ${{ vars.VITE_PUBLIC_SENTRY_DSN }} | |
VITE_PUBLIC_SENTRY_ENVIRONMENT: ${{ vars.VITE_PUBLIC_SENTRY_ENVIRONMENT }} | |
FUNCTIONS_SENTRY_ENVIRONMENT: ${{ vars.FUNCTIONS_SENTRY_ENVIRONMENT }} | |
- uses: netlify/actions/cli@master | |
with: | |
args: deploy --prod | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
run-integration-tests: | |
name: Run integration tests | |
runs-on: ubuntu-latest | |
needs: [deploy-to-production] | |
environment: production | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cypress-io/github-action@v6 | |
with: | |
record: true | |
browser: chrome | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
APP_TESTING_ENDPOINT: ${{ vars.APP_TESTING_ENDPOINT }} | |
- if: ${{ failure() }} | |
uses: netlify/actions/cli@master | |
with: | |
args: api rollbackSiteDeploy --data '{"site_id":"${{ env.NETLIFY_SITE_ID }}"}' | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |