From f29fcab398651196e539e2c07f77997e23958aea Mon Sep 17 00:00:00 2001 From: Vincent Liggio <2916193+vliggio@users.noreply.github.com> Date: Wed, 1 Apr 2026 23:57:32 -0400 Subject: [PATCH] Warn when pages deploy runs without git checkout (fixes #373) --- .changeset/warn-missing-checkout.md | 5 +++++ src/wranglerAction.ts | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/warn-missing-checkout.md diff --git a/.changeset/warn-missing-checkout.md b/.changeset/warn-missing-checkout.md new file mode 100644 index 00000000..aa40c86c --- /dev/null +++ b/.changeset/warn-missing-checkout.md @@ -0,0 +1,5 @@ +--- +"wrangler-action": patch +--- + +Warn when running `pages deploy` without a prior git checkout, which could cause unintended production deployments. diff --git a/src/wranglerAction.ts b/src/wranglerAction.ts index 92e0804f..59aeb963 100644 --- a/src/wranglerAction.ts +++ b/src/wranglerAction.ts @@ -10,9 +10,11 @@ import { getExecOutput } from "@actions/exec"; import semverSatisfies from "semver/functions/satisfies"; import semverValid from "semver/functions/valid"; import { z } from "zod"; +import { existsSync } from "node:fs"; +import { resolve } from "node:path"; import { exec, execShell } from "./exec"; import { PackageManager } from "./packageManagers"; -import { error, info, semverCompare } from "./utils"; +import { error, info, semverCompare, warn } from "./utils"; import { handleCommandOutputParsing } from "./commandOutputParsing"; import semverLt from "semver/functions/lt"; @@ -372,6 +374,18 @@ async function wranglerCommands( } } + if ( + (command.startsWith("pages deploy") || + command.startsWith("pages publish")) && + !existsSync(resolve(config["workingDirectory"], ".git")) + ) { + warn( + config, + "⚠️ No git checkout detected. Pages deploy may deploy to production instead of a preview environment. Ensure actions/checkout runs before this step.", + true, + ); + } + // Used for saving the wrangler output let stdOut = ""; let stdErr = "";