Skip to content

Commit 96f7802

Browse files
etchalonclaude
andcommitted
feat: Merge build-env into wrangler vars (wrangler config takes precedence)
build-env values are now added to the wrangler config vars section so they are available at runtime. Values defined in the wrangler environment file take precedence over build-env values. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 319702d commit 96f7802

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ runs:
265265
echo "Merging $ENV_FILE into $NITRO_CONFIG..."
266266
267267
# Pass file paths via environment variables to avoid escaping issues
268-
NITRO_CONFIG="$NITRO_CONFIG" ENV_FILE="$ENV_FILE" node --eval '
268+
NITRO_CONFIG="$NITRO_CONFIG" ENV_FILE="$ENV_FILE" BUILD_ENV='${{ inputs.build-env }}' node --eval '
269269
const fs = require("fs");
270270
271271
// Strip JSONC comments (handles strings correctly to not break URLs)
@@ -350,13 +350,20 @@ runs:
350350
351351
const nitroConfigPath = process.env.NITRO_CONFIG;
352352
const envFilePath = process.env.ENV_FILE;
353+
const buildEnvJson = process.env.BUILD_ENV || "{}";
353354
354355
// Read Nuxt-generated config (has main, assets, etc.)
355356
const nitroConfig = JSON.parse(fs.readFileSync(nitroConfigPath, "utf8"));
356357
357358
// Read and parse environment config (has bindings, vars, etc.)
358359
const envConfig = JSON.parse(stripJsonComments(fs.readFileSync(envFilePath, "utf8")));
359360
361+
// Parse build-env and add as base vars (wrangler env vars take precedence)
362+
const buildEnv = JSON.parse(buildEnvJson);
363+
if (Object.keys(buildEnv).length > 0) {
364+
envConfig.vars = { ...buildEnv, ...(envConfig.vars || {}) };
365+
}
366+
360367
// Merge: Nitro config + environment overrides
361368
const merged = deepMerge(nitroConfig, envConfig);
362369

0 commit comments

Comments
 (0)