Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warn-missing-checkout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler-action": patch
---

Warn when running `pages deploy` without a prior git checkout, which could cause unintended production deployments.
16 changes: 15 additions & 1 deletion src/wranglerAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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 = "";
Expand Down