Skip to content

Add CI/CD workflow for Vercel deployment and E2E testing; remove old … #1

Add CI/CD workflow for Vercel deployment and E2E testing; remove old …

Add CI/CD workflow for Vercel deployment and E2E testing; remove old … #1

name: CI/CD Workflow --> Deploy and Run E2E Tests
on:
pull_request:
push:
branches:
- main
jobs:
deploy-staging:
name: Deploy to Vercel Staging
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: |
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
- name: Build Project Artifacts
run: |
vercel build --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
- name: Deploy to Staging
id: deploy
run: |
DEPLOY_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1)
echo "DEPLOYMENT_URL=${DEPLOY_URL}" >> $GITHUB_ENV
echo "Deployed to: $DEPLOY_URL"
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
e2e-tests:
name: Run E2E Tests on Staging
runs-on: ubuntu-latest
needs: deploy-staging
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install pnpm
run: npm install -g pnpm
- name: Install Dependencies
run: pnpm install
- name: Install Playwright
run: pnpm playwright install
- name: Run Playwright Tests
run: pnpm playwright test
env:
BASE_URL: ${{ env.DEPLOYMENT_URL }}
deploy-prod:
name: Deploy to Vercel Production
runs-on: ubuntu-latest
needs: e2e-tests
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: |
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
- name: Build Project Artifacts
run: |
vercel build --prod --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
- name: Deploy to Production
run: |
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}