Skip to content

feat: add Workers Previews support - #442

Open
yomna-shousha wants to merge 6 commits into
cloudflare:mainfrom
yomna-shousha:feat/workers-previews-support
Open

feat: add Workers Previews support#442
yomna-shousha wants to merge 6 commits into
cloudflare:mainfrom
yomna-shousha:feat/workers-previews-support

Conversation

@yomna-shousha

@yomna-shousha yomna-shousha commented Jul 29, 2026

Copy link
Copy Markdown

What

Adds support for wrangler preview in wrangler-action. Preview commands now parse Wrangler Preview artifacts, expose Preview-specific outputs, and can create GitHub Deployments and job summaries when gitHubToken is provided.

The README documents the direct Wrangler workflow first, so users can copy plain GitHub Actions YAML without taking a dependency on this action. It then shows the wrangler-action wrapper for users who want action outputs, GitHub Deployments, and job summaries.

Changes

  • Adds a Zod schema for Wrangler Preview artifacts.
  • Parses preview command output and sets Preview outputs.
  • Adds fallback stdout parsing for Preview commands.
  • Creates non-production GitHub Deployments for Previews when gitHubToken is provided.
  • Renders a Workers Preview job summary.
  • Extends --var auto-injection to preview commands.
  • Adds README guidance for plain npx wrangler preview --json, wrangler-action, and deeper automation examples.
  • Adds a minor changeset so this ships in the next wrangler-action v4 release.

Outputs

Output Description
deployment-url Stable Preview URL, kept compatible with existing deployment URL usage
preview-url Stable Preview URL for the branch or Preview name
preview-deployment-url Immutable URL for the specific Preview deployment
preview-name Preview name
preview-id Preview resource ID
preview-deployment-id Deployment ID within the Preview

Example

Users can run Wrangler directly:

name: Preview

on: [pull_request]

jobs:
  preview:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - run: npx wrangler preview --json
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

Or use wrangler-action when they want Preview outputs, GitHub Deployments, and the job summary:

- uses: actions/checkout@v6
- id: preview
  uses: cloudflare/wrangler-action@v4
  with:
    apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
    accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
    command: preview
    gitHubToken: ${{ secrets.GITHUB_TOKEN }}

Verification

Local verification passes:

  • npm run build
  • npm test -- --run
  • npm run check

The wrangler_action_self_testing PR check currently fails at a live deployment fixture because this PR run does not have access to the Cloudflare secrets required by that workflow. The build, unit tests, and formatting steps in that same check pass before the secrets-backed fixture runs.

Add support for `wrangler preview` command output parsing,
GitHub Deployments, Job Summaries, and action outputs.

Changes:
- Add OutputEntryPreview Zod schema matching wrangler's preview artifact
- Parse preview artifacts and set outputs: preview-url, preview-name,
  preview-id, preview-deployment-url, preview-deployment-id
- Create GitHub Deployments for previews (non-production environment)
- Render Workers Preview Job Summary in GitHub Actions UI
- Extend --var auto-injection to preview commands
- Add preview deployment section to README with recommended workflow
- Add 5 new preview-specific outputs to action.yml
@yomna-shousha
yomna-shousha force-pushed the feat/workers-previews-support branch from 041882c to 4f66906 Compare July 29, 2026 15:31
@yomna-shousha
yomna-shousha marked this pull request as ready for review August 31, 2026 00:17
@yomna-shousha
yomna-shousha requested review from a team as code owners August 31, 2026 00:17
@yomna-shousha
yomna-shousha requested a review from penalosa August 31, 2026 00:17
Comment thread src/wranglerAction.ts Outdated
Comment thread src/service/github.ts Outdated
Comment thread src/wranglerArtifactManager.ts

@WillTaylorDev WillTaylorDev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing CI check, but doesn't look related to your changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants