Skip to content

Commit

Permalink
Refactor workflow to deploy before testing, with rollback on test fai…
Browse files Browse the repository at this point in the history
…lure.
  • Loading branch information
ad956 committed May 26, 2024
1 parent 87ba6a0 commit fe5ff0d
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main, master]

jobs:
test:
deploy-and-test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
Expand All @@ -17,6 +17,14 @@ jobs:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Vercel CLI
run: npm install --global vercel@canary
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
Expand All @@ -27,23 +35,6 @@ jobs:
name: playwright-report
path: playwright-report/
retention-days: 30

deploy:
needs: test
if: ${{ success() }}
runs-on: ubuntu-latest

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

steps:
- uses: actions/checkout@v4
- name: Install Vercel CLI
run: npm install --global vercel@canary
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Rollback Deployment on Test Failure
if: failure()
run: vercel rollback --prod --token=${{ secrets.VERCEL_TOKEN }}

0 comments on commit fe5ff0d

Please sign in to comment.