Skip to content

Fix Cloudflare Pages workflow Node runtime for Wrangler v4#483

Merged
sebdanielsson merged 3 commits into
mainfrom
copilot/update-cloudflare-pages-workflow
May 19, 2026
Merged

Fix Cloudflare Pages workflow Node runtime for Wrangler v4#483
sebdanielsson merged 3 commits into
mainfrom
copilot/update-cloudflare-pages-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Cloudflare Pages deploys were failing because cloudflare/wrangler-action@v4 requires Node.js 22+, while the job was running on Node 20. This updates the workflow to pin a compatible runtime and keeps CI checks non-mutating.

  • Workflow runtime compatibility

    • Add explicit Node setup before Wrangler:
      • actions/setup-node@v4
      • node-version: 24
    • Keep existing Bun-based install/lint/stylelint/build flow intact.
  • Cloudflare deploy step

    • Use cloudflare/wrangler-action@v4 in the deploy step.
  • CI formatting behavior

    • Change formatting step from write mode to check mode:
      • formatformat:check
    • Rename step label typo (Run formt checkRun format check).
- name: Setup Node.js 24
  uses: actions/setup-node@v4
  with:
    node-version: 24

- name: Run format check
  run: bun --bun run format:check

- name: Publish to Cloudflare Pages
  uses: cloudflare/wrangler-action@v4

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • backend.raycast.com
    • Triggering command: /tmp/bun-node-0d9b296af/node node /home/REDACTED/work/sebdanielsson.dev/sebdanielsson.dev/node_modules/.bin/astro check (dns block)
  • https://api.github.com/repos/sebdanielsson/hogwarts-docusaurus
    • Triggering command: /tmp/bun-node-0d9b296af/node node /home/REDACTED/work/sebdanielsson.dev/sebdanielsson.dev/node_modules/.bin/astro check (http block)
  • https://api.github.com/repos/sebdanielsson/infra
    • Triggering command: REDACTED, pid is -1 (http block)
  • telemetry.astro.build
    • Triggering command: /tmp/bun-node-0d9b296af/node node /home/REDACTED/work/sebdanielsson.dev/sebdanielsson.dev/node_modules/.bin/astro check (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Update the GitHub Actions workflow in repository sebdanielsson/sebdanielsson.dev to fix the failing Cloudflare Pages job at run 26072486501 / job 76656632181.

Observed failure:

  • The workflow uses cloudflare/wrangler-action@v4.
  • Job logs show Wrangler 4 requires Node.js v22+ but the runner has Node.js v20.20.0.
  • The workflow currently sets up Bun but does not explicitly set up Node.js.

Required fix:

  1. Modify .github/workflows/cloudflare-pages.yaml to explicitly install/setup Node.js before the Wrangler action.
  2. Use Node.js 24 specifically.
  3. Keep the existing Bun-based install/build/lint flow intact unless a minimal adjacent cleanup is clearly beneficial.
  4. If appropriate, also correct the CI formatting check step so CI checks formatting without writing files (for example, use format:check instead of format) if that is a safe improvement.
  5. Ensure the workflow remains valid YAML and should pass on GitHub Actions.

Please create a pull request with the workflow fix.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is in the Cloudflare deploy step, not in your app build.

Root cause

cloudflare/wrangler-action@v4 is trying to run Wrangler 4, but the job is using Node.js v20.20.0, and Wrangler now requires Node.js v22+.

From the logs:

  • Wrangler requires at least Node.js v22.0.0. You are using v20.20.0.
  • The failing workflow is cloudflare-pages.yaml

The relevant part is here:

You currently set up Bun, but not Node:

Solution

Add a Node 22 setup step before the Wrangler action.

Suggested workflow change

- name: Setup Bun
  uses: oven-sh/setup-bun@v2

- name: Setup Node.js
  uses: actions/setup-node@v4
  with:
    node-version: 22

- name: Install dependencies
  run: bun install --frozen-lockfile

Updated section

- name: Setup Bun
  uses: oven-sh/setup-bun@v2

- name: Setup Node.js
  uses: actions/setup-node@v4
  with:
    node-version: 22

- name: Install dependencies
  run: bun install --frozen-lockfile

- name: Run formt check
  run: bun --bun run format

- name: Run lint
  run: bun --bun run lint

- name: Run stylelint
  run: bun --bun run stylelint

- name: Build project
  run: bun --bun run build
  env:
    GITHUB_USER: ${{ github.repository_owner }}
    GITHUB_REPO: ${{ github.event.repository.name }}
    GH_API: ${{ steps.dotenvx.outputs.GH_API }}

- name: Publish to Cloudflare Pages
  uses: cloudflare/wrangler-action@v4
  with:
    apiToken: ${{ steps.dotenvx.outputs.CLOUDFLARE_API_TOKEN }}
    accountId: ${{ steps.dotenvx.outputs.CLOUDFLARE_ACCOUNT_ID }}
    command: "pages deploy dist --project-name=${{ steps.dotenvx.outputs.CLOUDFLARE_PROJECT_NAME }}"
    gitHubToken: ${{ secrets.GITHUB_TOKEN }}

Optional cleanup

Your workflow currently runs:

  • Run formt checkbun --bun run format

But in package.json, format is a write command:

"format": "prettier . --write",
"format:check": "prettier . --check"

For CI, this should probably be:

- name: Run format check
  run: bun --bun run format:check

Summary

Fix the job by adding actions/setup-node@v4 with node-version: 22 before cloudflare/wrangler-action@v4. That addresses the actual deploy failure.

User: Please create a PR with a fix and by using Node 24.

Assistant: I’ve started the PR creation for sebdanielsson/sebdanielsson.dev with the fix to set up Node 24 before the Cloudflare Wrangler deploy step, and I also included the safe CI cleanup to use a non-writing format check if applicable.

If the PR completes successfully, I can next help review the proposed diff or summarize exactly what changed.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Update Cloudflare Pages workflow to fix Node.js setup Fix Cloudflare Pages workflow Node runtime for Wrangler v4 May 19, 2026
Copilot AI requested a review from sebdanielsson May 19, 2026 06:22
@sebdanielsson sebdanielsson marked this pull request as ready for review May 19, 2026 06:23
Copilot AI review requested due to automatic review settings May 19, 2026 06:23
@sebdanielsson
Copy link
Copy Markdown
Owner

Run the formatting too @copilot

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Cloudflare Pages GitHub Actions workflow to ensure cloudflare/wrangler-action@v4 runs on a compatible Node.js runtime and to keep CI formatting checks non-mutating.

Changes:

  • Add an explicit actions/setup-node@v4 step configuring Node.js 24 before running Wrangler.
  • Switch the formatting step from format (write) to format:check (check-only) and fix the step name typo.
  • Bump the Cloudflare deploy step from cloudflare/wrangler-action@v3 to @v4.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 19, 2026

Run the formatting too @copilot

Done — I ran the formatter and committed the resulting formatting update in 212adc7.

@sebdanielsson sebdanielsson merged commit 0117d40 into main May 19, 2026
4 checks passed
@sebdanielsson sebdanielsson deleted the copilot/update-cloudflare-pages-workflow branch May 19, 2026 06:56
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.

3 participants