Skip to content

fix(cli): terminate each GITHUB_ENV/GITHUB_OUTPUT entry with a trailing newline#4059

Closed
codewithsupra wants to merge 1 commit into
triggerdotdev:mainfrom
codewithsupra:fix/github-actions-missing-trailing-newline
Closed

fix(cli): terminate each GITHUB_ENV/GITHUB_OUTPUT entry with a trailing newline#4059
codewithsupra wants to merge 1 commit into
triggerdotdev:mainfrom
codewithsupra:fix/github-actions-missing-trailing-newline

Conversation

@codewithsupra

Copy link
Copy Markdown

Problem

setGithubActionsOutputAndEnvVars in packages/cli-v3/src/utilities/githubActions.ts builds entries with .map(...).join('\n') — which separates entries but leaves the last entry without a trailing newline.

Both $GITHUB_ENV and $GITHUB_OUTPUT are job-scoped append files. Without a trailing newline, the last written entry (needsPromotion=...) is left on an unterminated line. Any subsequent write by the runner or another step can concatenate onto it, producing merged/malformed values like needsPromotion=trueSOME_OTHER_KEY=value — breaking promotion branching. The bug is intermittent because GitHub Actions sometimes inserts its own newline.

Fix

Match the @actions/core convention — every entry gets its own trailing \n:

- .map(([key, value]) => `${key}=${value}`)
- .join("\n");
+ .map(([key, value]) => `${key}=${value}\n`)
+ .join("");

Applied to both the GITHUB_ENV and GITHUB_OUTPUT writes.

Fixes #4003

.join('\n') only separates entries — it leaves the last KEY=value on an
unterminated line. A subsequent write to the same runner-scoped file can
merge onto that unterminated tail, corrupting the needsPromotion output
and any other entries that follow.

Match the @actions/core convention: each entry gets its own trailing
newline. Switch from .map(...).join('\n') to .map(... + '\n').join('')
so every line is properly terminated regardless of how many entries are
written.

Fixes triggerdotdev#4003
@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9380b53

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Hi @codewithsupra, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 26fbcd38-12bb-491e-8f82-1eb04b7809ed

📥 Commits

Reviewing files that changed from the base of the PR and between 2cc1743 and 9380b53.

📒 Files selected for processing (1)
  • packages/cli-v3/src/utilities/githubActions.ts

Walkthrough

The change updates setGithubActionsOutputAndEnvVars so both GITHUB_ENV and GITHUB_OUTPUT content strings are built by adding a trailing newline to each key=value entry and joining with an empty separator. The file append calls remain unchanged.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

setGithubActionsOutputAndEnvVars writes GITHUB_ENV/GITHUB_OUTPUT entries without a trailing newline

1 participant