Update main.yml #6
This file contains hidden or 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 and Run E2E Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| deploy: | |
| name: Deploy to Vercel | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Install Vercel CLI | |
| run: npm install -g vercel | |
| - name: Deploy to Vercel | |
| id: deploy | |
| run: | | |
| vercel pull --yes --environment=preview --token ${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | |
| DEPLOY_URL=$(vercel deploy --staging --token ${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1) | |
| echo "DEPLOYMENT_URL=${DEPLOY_URL}" >> $GITHUB_ENV | |
| echo "Deployed to: $DEPLOY_URL" | |
| env: | |
| # VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| # VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | |
| e2e: | |
| name: Run E2E Tests | |
| runs-on: ubuntu-latest | |
| needs: deploy | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Install Playwright | |
| run: npx playwright install | |
| - name: Run Playwright Tests | |
| run: npx playwright test | |
| env: | |
| BASE_URL: ${{ env.DEPLOYMENT_URL }} |