1- # name: Playwright Tests
2-
3- # on:
4- # deployment_status:
5-
6- # jobs:
7- # run-e2es:
8- # if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' && github.ref != 'refs/heads/main'
9- # runs-on: ubuntu-latest
10- # steps:
11- # - name: Checkout repository
12- # uses: actions/checkout@v4
13-
14- # - name: Install dependencies
15- # run: npm ci && npx playwright install --with-deps
16-
17- # - name: Create PandaDoc Webhook
18- # id: pandadoc-webhook
19- # run: |
20- # RESPONSE=$(curl -X POST "https://api.pandadoc.com/public/v1/webhooks" \
21- # -H "Authorization: Bearer ${{ env.PANDADOC_API_KEY }}" \
22- # -H "Content-Type: application/json" \
23- # -d '{
24- # "name": "drpcrd-staging",
25- # "url": "${{ github.event.deployment_status.environment_url }}/api/webhook/pandadoc",
26- # "event_types": [
27- # "document.creation_failed",
28- # "document.deleted",
29- # "document.section_added",
30- # "document.state_changed",
31- # "document.updated",
32- # "document.completed",
33- # "pdf.completed",
34- # "recipient.completed_document"
35- # ]
36- # }')
37-
38- # SHARED_KEY=$(echo "$RESPONSE" | jq -r '.shared_key')
39- # echo "PANDADOC_WEBHOOK_SHARED_KEY=$SHARED_KEY" >> $GITHUB_ENV
40-
41- # - name: Run Playwright tests
42- # env:
43- # BASE_URL: ${{ github.event.deployment_status.environment_url }}
44- # run: npx playwright test
45-
46- # - name: Upload Playwright Report
47- # uses: actions/upload-artifact@v4
48- # if: always()
49- # with:
50- # name: playwright-report
51- # path: playwright-report/
52- # retention-days: 7
53-
54- # - name: GitHub Notification
55- # if: failure()
56- # uses: actions/github-script@v6
57- # with:
58- # script: |
59- # github.issues.createComment({
60- # issue_number: 1,
61- # owner: context.repo.owner,
62- # repo: context.repo.repo,
63- # body: "🚨 Playwright tests failed after deployment!"
64- # });
65-
661name : Playwright Tests
672
683on :
@@ -74,63 +9,18 @@ permissions:
749
7510jobs :
7611 run-e2es :
77- if : github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'staging '
12+ if : github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview '
7813 runs-on : ubuntu-latest
7914 steps :
15+ - name : Print environment
16+ run : echo ${{ github.event.deployment_status.environment }}
17+
8018 - name : Checkout repository
8119 uses : actions/checkout@v4
8220
8321 - name : Install dependencies
8422 run : npm ci && npx playwright install --with-deps
8523
86- - name : Create PandaDoc Webhook
87- id : pandadoc-webhook
88- run : |
89- # Check if PANDADOC_API_KEY is set
90- if [[ -z "${{ env.PANDADOC_API_KEY }}" ]]; then
91- echo "❌ PandaDoc API Key is missing!"
92- exit 1
93- fi
94-
95- # Make the API request
96- RESPONSE=$(curl -s -X POST "https://api.pandadoc.com/public/v1/webhooks" \
97- -H "Authorization: Bearer ${{ env.PANDADOC_API_KEY }}" \
98- -H "Content-Type: application/json" \
99- -d '{
100- "name": "drpcrd-staging",
101- "url": "'"${{ github.event.deployment_status.environment_url }}"'/api/webhook/pandadoc",
102- "event_types": [
103- "document.creation_failed",
104- "document.deleted",
105- "document.section_added",
106- "document.state_changed",
107- "document.updated",
108- "document.completed",
109- "pdf.completed",
110- "recipient.completed_document"
111- ]
112- }')
113-
114- # Validate the response before using jq
115- if [[ -z "$RESPONSE" || "$RESPONSE" == "null" ]]; then
116- echo "❌ Error: No response received from PandaDoc API"
117- exit 1
118- fi
119-
120- echo "📩 API Response: $RESPONSE"
121-
122- # Extract shared_key from response using jq
123- SHARED_KEY=$(echo "$RESPONSE" | jq -r '.shared_key')
124-
125- # Check if shared_key is valid
126- if [[ "$SHARED_KEY" == "null" || -z "$SHARED_KEY" ]]; then
127- echo "❌ Failed to create PandaDoc webhook. API response: $RESPONSE"
128- exit 1
129- fi
130-
131- echo "✅ PandaDoc Webhook Created Successfully!"
132- echo "PANDADOC_WEBHOOK_SHARED_KEY=$SHARED_KEY" >> $GITHUB_ENV
133-
13424 - name : Run Playwright tests
13525 env :
13626 BASE_URL : ${{ github.event.deployment_status.environment_url }}
0 commit comments