Playwright Tests #8
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: Playwright Tests | |
| on: | |
| deployment_status: | |
| defaults: | |
| run: | |
| working-directory: ./ | |
| permissions: | |
| contents: read | |
| issues: write # ✅ Required for issue comments | |
| jobs: | |
| run-e2es: | |
| if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' && github.ref != 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| name: Run E2E tests | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| run_install: false | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile && pnpm exec playwright install --with-deps # ✅ Fix Playwright issue | |
| - name: Create PandaDoc Webhook | |
| id: pandadoc-webhook | |
| run: | | |
| RESPONSE=$(curl -X POST "https://api.pandadoc.com/public/v1/webhooks" \ | |
| -H "Authorization: Bearer ${{ env.PANDADOC_API_KEY }}" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "name": "drpcrd-staging", | |
| "url": "${{ github.event.deployment_status.environment_url }}/api/webhook/pandadoc", | |
| "event_types": [ | |
| "document.creation_failed", | |
| "document.deleted", | |
| "document.section_added", | |
| "document.state_changed", | |
| "document.updated", | |
| "document.completed", | |
| "pdf.completed", | |
| "recipient.completed_document" | |
| ] | |
| }') | |
| SHARED_KEY=$(echo "$RESPONSE" | jq -r '.shared_key') | |
| echo "PANDADOC_WEBHOOK_SHARED_KEY=$SHARED_KEY" >> $GITHUB_ENV | |
| - name: Run E2E tests | |
| env: | |
| NEXT_PUBLIC_URL: ${{ github.event.deployment_status.environment_url }} | |
| run: pnpm test:e2e | |
| - name: Upload Playwright Report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: reports | |
| path: playwright/reports/ | |
| retention-days: 7 | |
| - name: GitHub Notification | |
| if: failure() | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} # ✅ Fix GitHub API auth | |
| script: | | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: 1, | |
| body: "🚨 Playwright tests failed after deployment!" | |
| }); |