diff --git a/.changeset/github-actions-trailing-newline.md b/.changeset/github-actions-trailing-newline.md new file mode 100644 index 00000000000..52c81f52422 --- /dev/null +++ b/.changeset/github-actions-trailing-newline.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +Terminate each GITHUB_ENV and GITHUB_OUTPUT entry with a trailing newline so later appends cannot merge onto the last value. diff --git a/packages/cli-v3/src/utilities/githubActions.ts b/packages/cli-v3/src/utilities/githubActions.ts index a4a80e75a1e..9a5e4b34524 100644 --- a/packages/cli-v3/src/utilities/githubActions.ts +++ b/packages/cli-v3/src/utilities/githubActions.ts @@ -7,11 +7,12 @@ export function setGithubActionsOutputAndEnvVars({ envVars: Record; outputs: Record; }) { - // Set environment variables + // Set environment variables. Terminate each entry with a newline so a + // subsequent append cannot concatenate onto the last KEY=value line. if (process.env.GITHUB_ENV) { const contents = Object.entries(envVars) - .map(([key, value]) => `${key}=${value}`) - .join("\n"); + .map(([key, value]) => `${key}=${value}\n`) + .join(""); appendFileSync(process.env.GITHUB_ENV, contents); } @@ -19,8 +20,8 @@ export function setGithubActionsOutputAndEnvVars({ // Set outputs if (process.env.GITHUB_OUTPUT) { const contents = Object.entries(outputs) - .map(([key, value]) => `${key}=${value}`) - .join("\n"); + .map(([key, value]) => `${key}=${value}\n`) + .join(""); appendFileSync(process.env.GITHUB_OUTPUT, contents); }