Skip to content

Commit 9446a5f

Browse files
committed
fix(workflow): address Cursor Bugbot findings on upgrade-deps PR
- Guarantee a trailing newline on commit-message.txt and pr-body.md before piping them through the heredoc into `$GITHUB_OUTPUT`. If Claude overwrites either file without a final `\n`, `cat` leaves the last line adjacent to the closing delimiter and GitHub Actions never terminates the multi-line value — producing a garbled body/commit. - Fail fast in `updatePnpmWorkspace` when a version regex no longer matches the YAML. Previously we silently recorded `(unset) -> new` even though `.replace` was a no-op, which would ship a misleading dependency table. A stale pattern now surfaces as an explicit error so the script can be updated.
1 parent 1365243 commit 9446a5f

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

.github/scripts/upgrade-deps.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ async function updatePnpmWorkspace(versions) {
134134

135135
for (const { name, pattern, replacement, newVersion } of entries) {
136136
const oldVersion = content.match(pattern)?.[1];
137+
if (!oldVersion) {
138+
throw new Error(
139+
`Failed to match ${name} in pnpm-workspace.yaml — the pattern ${pattern} is stale, ` +
140+
`please update it in .github/scripts/upgrade-deps.mjs`,
141+
);
142+
}
137143
content = content.replace(pattern, replacement);
138144
recordChange(name, oldVersion, newVersion);
139145
}

.github/workflows/upgrade-deps.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,17 @@ jobs:
228228
COMMIT_FILE="${UPGRADE_DEPS_META_DIR}/commit-message.txt"
229229
BODY_FILE="${UPGRADE_DEPS_META_DIR}/pr-body.md"
230230
231+
# GitHub Actions heredoc outputs require the terminator on its own line,
232+
# so guarantee a trailing newline regardless of what the generator wrote.
233+
ensure_trailing_newline() {
234+
local f="$1"
235+
if [ -s "$f" ] && [ -n "$(tail -c1 "$f")" ]; then
236+
printf '\n' >> "$f"
237+
fi
238+
}
239+
ensure_trailing_newline "${COMMIT_FILE}"
240+
ensure_trailing_newline "${BODY_FILE}"
241+
231242
echo '--- commit-message.txt ---'
232243
cat "${COMMIT_FILE}"
233244
echo '--- pr-body.md ---'

0 commit comments

Comments
 (0)