From 51274094821ddd5f002936697978820dcd0f90e5 Mon Sep 17 00:00:00 2001 From: Anand Suthar Date: Mon, 15 Jul 2024 15:19:35 +0530 Subject: [PATCH] Update CI/CD workflow for Playwright tests - Remove staging deployment job - Adjust production deployment conditions - Update workflow name to reflect current purpose This commit updates our GitHub Actions workflow to focus on running Playwright tests and deploying to production. --- .github/workflows/playwright.yml | 58 +++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 4a0fb12..26ab808 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,14 +1,13 @@ -name: Playwright Tests and Vercel Deployment +name: CI/CD Pipeline For Playwright Tests and Vercel Deployment on: push: - branches: [main, master] + branches: [main] pull_request: - branches: [main, master] + branches: [main] jobs: - deploy-and-test: - timeout-minutes: 60 + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -17,24 +16,45 @@ 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 linter + run: npm run lint - name: Run Playwright tests - run: npx playwright test + run: npm test - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: name: playwright-report path: playwright-report/ retention-days: 30 - - name: Rollback Deployment on Test Failure - if: ${{ failure() }} - run: vercel rollback --token=${{ secrets.VERCEL_TOKEN }} + + # deploy-staging: + # needs: test + # if: github.event_name == 'push' && github.ref == 'refs/heads/develop' + # 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 Staging + # 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 + run: vercel deploy --token=${{ secrets.VERCEL_TOKEN }}