Both Playwright-on-Vercel workflows fail at the very first action
(`patrickedqvist/wait-for-vercel-preview@v1.3.2`) with 403 "Resource
not accessible by integration". The cause is the repo-default workflow
token being read-only-by-default with no scopes declared by the workflow.
Add minimal scoped permission blocks per the GitHub Actions least-privilege
guidance:
preview-smoke.yml:
contents: read
deployments: read # wait-for-vercel-preview queries GitHub Deployments
pull-requests: read # correlate deployment with this PR
statuses: read # some Vercel deployments use commit statuses
visual-diff.yml:
contents: read
deployments: read
pull-requests: write # final step posts "Visual Diff" comment via Issues API
statuses: read
Verified against the failure on PR #15:
- Playwright smoke: "Resource not accessible by integration" on
wait-for-vercel-preview → fixed by deployments+statuses+pull-requests:read
- Screenshot diff: 403 from POST /repos/.../issues/15/comments with
`x-accepted-github-permissions: issues=write; pull_requests=write`
in the response → fixed by pull-requests:write (covers Issues API
for PR comments; issues:write would also work but pull-requests:write
is the idiomatic scope)
Unblocks visual-regression signal on every future PR. No code changes,
no test changes — workflow YAML only.
Co-authored-by: Cursor <cursoragent@cursor.com>
88 lines
2.7 KiB
YAML
88 lines
2.7 KiB
YAML
name: Preview smoke
|
|
|
|
# Waits for Vercel's per-PR Preview deployment to be ready, then runs
|
|
# Playwright smoke against its URL.
|
|
#
|
|
# Vercel's GitHub integration auto-deploys every push and posts a Deployment
|
|
# to the GitHub API once ready. We wait on that Deployment so we always hit
|
|
# the canonical preview URL Vercel just published.
|
|
#
|
|
# REQUIRES: @playwright/test installed. Until then, this workflow will fail
|
|
# on `npx playwright install`. See .convoys/ for the testing convoy.
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
types: [labeled, opened, synchronize, reopened]
|
|
|
|
concurrency:
|
|
group: preview-smoke-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
# Default workflow token is read-only on this repo. The `wait-for-vercel-preview`
|
|
# action needs `deployments: read` to query Vercel's GitHub Deployment status,
|
|
# plus `statuses: read` because some Vercel deployments use commit statuses
|
|
# instead of the Deployments API. `pull-requests: read` lets it correlate the
|
|
# deployment back to this PR. Without these, the action 403s on the Checks API
|
|
# and the smoke job fails before Playwright even starts.
|
|
permissions:
|
|
contents: read
|
|
deployments: read
|
|
pull-requests: read
|
|
statuses: read
|
|
|
|
jobs:
|
|
gate:
|
|
name: Should run?
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_run: ${{ steps.check.outputs.should_run }}
|
|
steps:
|
|
- name: Decide
|
|
id: check
|
|
run: |
|
|
if echo "${{ github.event.pull_request.body }}" | grep -qE 'pipeline:.*skip.*\bsmoke\b'; then
|
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
|
echo "::notice::Smoke skipped via pipeline directive"
|
|
else
|
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
smoke:
|
|
name: Playwright smoke
|
|
needs: gate
|
|
if: needs.gate.outputs.should_run == 'true'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Wait for Vercel Preview deployment
|
|
id: vercel
|
|
uses: patrickedqvist/wait-for-vercel-preview@v1.3.2
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
max_timeout: 600
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: npm
|
|
|
|
- run: npm ci
|
|
|
|
- name: Install Playwright browsers
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Run smoke tests
|
|
run: npx playwright test --project=smoke
|
|
env:
|
|
BASE_URL: ${{ steps.vercel.outputs.url }}
|
|
|
|
- name: Upload Playwright report on failure
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report
|
|
path: playwright-report/
|
|
retention-days: 7
|