Skip to content

Refactor API Endpoints for Consistent Error Handling 🌟 #145

Refactor API Endpoints for Consistent Error Handling 🌟

Refactor API Endpoints for Consistent Error Handling 🌟 #145

name: CI/CD Pipeline For Playwright Tests and Vercel Deployment
on:
push:
branches: [main, "feature/**"]
pull_request:
branches: [main, "feature/**"]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache dependencies
uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Cache Playwright browsers
uses: actions/[email protected]
with:
path: ~/.cache/ms-playwright
key: ${{ runner.OS }}-playwright-${{ hashFiles('**/package-lock.json') }}
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npm test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
deploy-preview:
needs: test
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/feature/'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- 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 }}
- name: Deploy to Vercel Preview
run: vercel deploy --token=${{ secrets.VERCEL_TOKEN }}
deploy-production:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- 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 }}
- name: Deploy to Vercel Production
run: vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }}