Skip to content

Commit 1a88ebb

Browse files
refactor GitHub Actions workflow for Playwright tests and remove unused steps
1 parent e89ea76 commit 1a88ebb

File tree

1 file changed

+44
-51
lines changed

1 file changed

+44
-51
lines changed

.github/workflows/panda-webhook.yml

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,60 @@ name: Playwright Tests
33
on:
44
deployment_status:
55

6+
defaults:
7+
run:
8+
working-directory: ./
9+
10+
permissions:
11+
contents: read # for checkout repository
12+
613
jobs:
714
run-e2es:
8-
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' && github.ref != 'refs/heads/main' && github.event.deployment_status.environment == 'staging'
15+
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' && github.ref != 'refs/heads/main'
916
runs-on: ubuntu-latest
17+
name: Run E2E tests
1018
steps:
1119
- name: Checkout repository
1220
uses: actions/checkout@v4
1321

14-
- name: Install dependencies
15-
run: npm ci && npx playwright install --with-deps
22+
# - name: Install Node.js
23+
# uses: actions/setup-node@v4
24+
# with:
25+
# node-version: 20
1626

17-
- name: Fetch Required Secrets from Vercel API
18-
id: fetch-secrets
19-
run: |
20-
# Fetch Vercel Project ID
21-
VERCEL_PROJECT_ID=$(curl -s -X GET "https://api.vercel.com/v9/projects" \
22-
-H "Authorization: Bearer $(curl -s "https://api.vercel.com/v9/projects/drpcrd-staging/env" | jq -r '.envs[] | select(.key=="VERCEL_API_KEY") | .value')" \
23-
| jq -r '.projects[] | select(.name=="drpcrd-staging") | .id')
27+
# - name: Install pnpm
28+
# uses: pnpm/action-setup@v4
29+
# with:
30+
# version: latest
31+
# run_install: false
32+
33+
# - name: Get pnpm store directory
34+
# shell: bash
35+
# run: |
36+
# echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
2437

25-
# Fetch Vercel API Key
26-
VERCEL_API_KEY=$(curl -s "https://api.vercel.com/v9/projects/$VERCEL_PROJECT_ID/env" \
27-
| jq -r '.envs[] | select(.key=="VERCEL_API_KEY") | .value')
38+
# - name: Setup pnpm cache
39+
# uses: actions/cache@v4
40+
# with:
41+
# path: ${{ env.STORE_PATH }}
42+
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43+
# restore-keys: |
44+
# ${{ runner.os }}-pnpm-store-
2845

29-
# Fetch PandaDoc API Key
30-
PANDADOC_API_KEY=$(curl -s "https://api.vercel.com/v9/projects/$VERCEL_PROJECT_ID/env" \
31-
| jq -r '.envs[] | select(.key=="PANDADOC_API_KEY") | .value')
46+
# - name: Install packages
47+
# run: pnpm install --frozen-lockfile
3248

33-
# Export to GitHub Actions env
34-
echo "VERCEL_PROJECT_ID=$VERCEL_PROJECT_ID" >> $GITHUB_ENV
35-
echo "VERCEL_API_KEY=$VERCEL_API_KEY" >> $GITHUB_ENV
36-
echo "PANDADOC_API_KEY=$PANDADOC_API_KEY" >> $GITHUB_ENV
49+
- name: Install Playwright dependencies
50+
run: pnpm exec playwright install-deps
3751

38-
- name: Create PandaDoc Webhook (drpcrd-staging)
52+
- name: Install Playwright
53+
run: pnpm exec playwright install
54+
55+
- name: Create PandaDoc Webhook
3956
id: pandadoc-webhook
4057
run: |
4158
RESPONSE=$(curl -X POST "https://api.pandadoc.com/public/v1/webhooks" \
42-
-H "Authorization: Bearer $PANDADOC_API_KEY" \
59+
-H "Authorization: Bearer ${{ env.PANDADOC_API_KEY }}" \
4360
-H "Content-Type: application/json" \
4461
-d '{
4562
"name": "drpcrd-staging",
@@ -59,40 +76,16 @@ jobs:
5976
SHARED_KEY=$(echo "$RESPONSE" | jq -r '.shared_key')
6077
echo "PANDADOC_WEBHOOK_SHARED_KEY=$SHARED_KEY" >> $GITHUB_ENV
6178
62-
- name: Store PandaDoc Webhook Key in Vercel
63-
run: |
64-
curl -X PATCH "https://api.vercel.com/v9/projects/$VERCEL_PROJECT_ID/env/PANDADOC_WEBHOOK_SHARED_KEY" \
65-
-H "Authorization: Bearer $VERCEL_API_KEY" \
66-
-H "Content-Type: application/json" \
67-
-d '{
68-
"value": "'${{ env.PANDADOC_WEBHOOK_SHARED_KEY }}'",
69-
"target": ["preview", "production"]
70-
}'
71-
72-
- name: Restart Vercel Deployment to Load Env Variables
73-
run: |
74-
curl -X POST "https://api.vercel.com/v13/deployments" \
75-
-H "Authorization: Bearer $VERCEL_API_KEY" \
76-
-H "Content-Type: application/json" \
77-
-d '{
78-
"name": "drpcrd-staging",
79-
"target": "staging"
80-
}'
81-
82-
- name: Wait for Deployment to Complete
83-
run: sleep 30 # Allow time for the environment variables to take effect
84-
85-
- name: Run Playwright Tests
79+
- name: Run E2E tests
8680
env:
87-
BASE_URL: ${{ github.event.deployment_status.environment_url }}
88-
run: npx playwright test
81+
NEXT_PUBLIC_URL: ${{ github.event.deployment_status.environment_url }}
82+
run: pnpm test:e2e
8983

9084
- name: Upload Playwright Report
9185
uses: actions/upload-artifact@v4
92-
if: always()
9386
with:
94-
name: playwright-report
95-
path: playwright-report/
87+
name: reports
88+
path: playwright/reports/
9689
retention-days: 7
9790

9891
- name: GitHub Notification

0 commit comments

Comments
 (0)