Browser flows against a preview
Preview deployments
Section titled “Preview deployments”Set target: preview to test the pull request's deployed app without an application image or start command. Preview runs start only on pull_request events of types labeled, synchronize and reopened. Both the caller and the reusable workflow refuse forks before the job with secrets starts. The coordinator also refuses forks, skips drafts and requires the preview label. Only apply that label to code you trust to test with the preview's seeded data.
| Input | Meaning | Default |
|---|---|---|
target |
container or preview |
container |
preview-environments |
Deployment environment patterns, space or comma separated. * matches any text, names are case sensitive |
Required for preview |
preview-hosts |
Allowed hostnames, exact or *.suffix, space or comma separated |
Required for preview |
preview-creators |
Allowed deployment and status creator logins, space or comma separated | Required for preview |
preview-label |
Label the pull request must carry | hawk-browser-flows |
preview-bypass |
none, vercel or cloudflare-access |
none |
preview-bypass-secret |
Vercel automation bypass secret or Cloudflare Access service token secret | Unset |
preview-bypass-client-id |
Cloudflare Access service token client id | Unset |
preview-wait-seconds |
Polling deadline in seconds, an integer from 30 to 1800 | 600 |
Confirm the environment names and creator logins on your own repository's Deployments page. There are no host-specific defaults. Preview and vercel[bot] below are examples for a Vercel integration. Set preview-environments and preview-creators to the values your host actually posts.
Code Hawk polls the deployments API for the PR head SHA every 15 seconds, for up to preview-wait-seconds. It excludes production deployments and requires both the deployment and its latest allowed status to have a creator in preview-creators. The newest matching deployment wins. Success starts the flows. Failure or error posts a failed-deployment comment and fails the job. If no matching preview succeeds before the deadline, including a pending or inactive preview, the missing-preview comment states how long it waited and the job fails. A failed lookup is retried once after 15 seconds, then reported by its step without API error details.
Only the status's environment_url is used, never log_url or target_url. The address must use HTTPS, contain no credentials or port, and have a hostname in preview-hosts. Exact entries match only that hostname. *.vercel.app permits subdomains of vercel.app, including nested subdomains, but not vercel.app itself. IP addresses and trailing-dot hosts are refused. Paths, queries and fragments are dropped, so the browser and readiness probe use the accepted origin. base-url and --base-url are ignored, and --local-out is refused. Omit application-image and application-command in preview mode.
For protected Vercel previews, preview-bypass: vercel sends the lowercase x-vercel-protection-bypass header. It never sends x-vercel-set-bypass-cookie or adds the secret to a query parameter. For Cloudflare Access, preview-bypass: cloudflare-access needs both service token values. It sends CF-Access-Client-Id and CF-Access-Client-Secret as lowercase headers cf-access-client-id and cf-access-client-secret. Netlify has no documented bypass for protected Deploy Previews, so use an unprotected preview or container mode. Bypass headers go only to the preview origin, with redirects fetched without forwarding them. Readiness requires a 2xx response from the preview origin. A 3xx response is an environment blocker that names the redirect status and suggests checking the bypass secret or preview address. An HTTP 401 or 403 readiness refusal names the missing bypass configuration as an environment blocker.
Use the shared flow library and recording bucket setup. The preview must have its own seeded test data. Test users, passwords and authenticator seeds must exist only in that preview's seeded data, never in production or another shared environment. Application logs are not provided for previews, so diagnosis uses browser evidence only. Results identify the preview origin, environment and deployment id. The browser still runs in a container and loads the caller's pinned @playwright/test from node_modules, so dependencies are installed without secrets as in the container caller.
name: Code Hawk previewon: pull_request: types: [labeled, synchronize, reopened]permissions: contents: readconcurrency: group: codehawk-preview-${{ github.event.pull_request.number }} cancel-in-progress: truejobs: flows: if: >- github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft && contains(github.event.pull_request.labels.*.name, 'hawk-browser-flows') permissions: contents: read id-token: write uses: bts-io/codehawk/.github/workflows/preview-flows.yml@<sha> with: preview_environments: Preview preview_hosts: "*.vercel.app" preview_creators: vercel[bot] preview_bypass: vercel s3_endpoint: ${{ vars.CODEHAWK_S3_ENDPOINT }} s3_bucket: ${{ vars.CODEHAWK_S3_BUCKET }} s3_region: ${{ vars.CODEHAWK_S3_REGION || 'auto' }} secrets: CODEHAWK_OPENAI_API_KEY: ${{ secrets.CODEHAWK_OPENAI_API_KEY }} CODEHAWK_ANTHROPIC_API_KEY: ${{ secrets.CODEHAWK_ANTHROPIC_API_KEY }} CODEHAWK_GOOGLE_API_KEY: ${{ secrets.CODEHAWK_GOOGLE_API_KEY }} CODEHAWK_GATEWAY_TOKEN: ${{ secrets.CODEHAWK_GATEWAY_TOKEN }} CODEHAWK_PREVIEW_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }} CODEHAWK_S3_ACCESS_KEY_ID: ${{ secrets.CODEHAWK_S3_ACCESS_KEY_ID }} CODEHAWK_S3_SECRET_ACCESS_KEY: ${{ secrets.CODEHAWK_S3_SECRET_ACCESS_KEY }}Replace <sha> with the Code Hawk commit you pin. The App token needs deployments read, contents read and pull requests write on this repository. Use only the pull_request trigger, which withholds secrets from fork runs. Do not add a deployment event trigger to this caller, since it could run fork-authored workflow code with repository secrets.
The reusable workflow separates preparation, browser execution and reporting. Preparation reads default-branch settings through resolveSetup and looks up the preview. Preparation and reporting use actions/token with contents: read, pull_requests: write and deployments: read, with id-token: write on their jobs. Neither job checks out the PR head or installs caller dependencies. The browser job checks out the PR with persist-credentials: false, installs dependencies in a container without secrets, and receives no App token or OIDC access. Only JSON context and a Markdown report cross the job boundaries.
Pass provider, bypass and storage keys as explicit named secrets. The four provider secrets are CODEHAWK_OPENAI_API_KEY, CODEHAWK_ANTHROPIC_API_KEY, CODEHAWK_GOOGLE_API_KEY and CODEHAWK_GATEWAY_TOKEN. The legacy inference input and eight credential slots remain optional for one release. The workflow also accepts the older CODE_REVIEW_HAWK_ App, slot, bypass and storage names, with CODEHAWK_ values taking precedence. The hosted App needs no App ID or private key. For your own App, set app_id and forward CODEHAWK_PRIVATE_KEY.
See browser flow results for what the report includes.