Skip to content

Commit 9636d98

Browse files
fix: resolve all YAML template literal issues in merge-bot workflow (#22)
* fix: resolve YAML syntax error in merge-bot workflow template literal Fix template literal interpolation issue by extracting pr.base.ref to a local variable before using it in the comment body. This prevents YAML parsing errors with the GitHub Actions workflow. The issue occurs when GitHub Actions tries to parse the workflow file and encounters ${pr.base.ref} inside a JavaScript template literal, which can be confused with GitHub Actions variable interpolation syntax. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: resolve all YAML template literal issues in merge-bot workflow Replace all problematic template literals with backticks inside YAML with array-based string construction using .join('\n'). This prevents YAML parser errors when GitHub Actions tries to validate the workflow file. Changes: - Fork PR message: Use array of strings instead of multiline template literal - Success message: Extract to variable to avoid inline template complexity - Failure message: Use array of strings for code block formatting This approach avoids: - Escaped backticks in YAML (\`\`\`) - Complex template literals inside YAML string literals - YAML scanner errors with 'could not find expected :' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f3dd729 commit 9636d98

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

.github/workflows/merge-bot.yml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -410,21 +410,25 @@ jobs:
410410
core.setOutput('is_fork', 'true');
411411
412412
const baseBranch = pr.base.ref;
413+
const forkMessage = [
414+
'ℹ️ Update commands are not supported for PRs from forks.',
415+
'',
416+
'To update your branch, please run these commands locally:',
417+
'',
418+
'```bash',
419+
`git fetch upstream ${baseBranch}`,
420+
`git merge upstream/${baseBranch}`,
421+
'git push',
422+
'```',
423+
'',
424+
'Or create a new PR from the same repository.'
425+
].join('\n');
426+
413427
await github.rest.issues.createComment({
414428
owner: context.repo.owner,
415429
repo: context.repo.repo,
416430
issue_number: context.payload.issue.number,
417-
body: `ℹ️ Update commands are not supported for PRs from forks.
418-
419-
To update your branch, please run these commands locally:
420-
421-
\`\`\`bash
422-
git fetch upstream ${baseBranch}
423-
git merge upstream/${baseBranch}
424-
git push
425-
\`\`\`
426-
427-
Or create a new PR from the same repository.`
431+
body: forkMessage
428432
});
429433
430434
return;
@@ -600,13 +604,13 @@ Or create a new PR from the same repository.`
600604
const baseBranch = '${{ steps.pr_info.outputs.base_branch }}';
601605
const commitsBehind = '${{ steps.check_update.outputs.commits_behind }}';
602606
607+
const successMessage = `✅ Branch updated successfully by @${user}!\n\nMerged ${commitsBehind} commit(s) from \`${baseBranch}\`.`;
608+
603609
await github.rest.issues.createComment({
604610
owner: context.repo.owner,
605611
repo: context.repo.repo,
606612
issue_number: context.payload.issue.number,
607-
body: `✅ Branch updated successfully by @${user}!
608-
609-
Merged ${commitsBehind} commit(s) from \`${baseBranch}\`.`
613+
body: successMessage
610614
});
611615
612616
// Add +1 reaction to original comment
@@ -624,21 +628,25 @@ Merged ${commitsBehind} commit(s) from \`${baseBranch}\`.`
624628
script: |
625629
const baseBranch = '${{ steps.pr_info.outputs.base_branch }}';
626630
631+
const failureMessage = [
632+
`❌ Failed to update branch with latest changes from \`${baseBranch}\`.`,
633+
'',
634+
'This usually means there are merge conflicts that need to be resolved manually.',
635+
'',
636+
'Please update your branch locally:',
637+
'```bash',
638+
`git fetch origin ${baseBranch}`,
639+
`git merge origin/${baseBranch}`,
640+
'# Resolve conflicts',
641+
'git push',
642+
'```'
643+
].join('\n');
644+
627645
await github.rest.issues.createComment({
628646
owner: context.repo.owner,
629647
repo: context.repo.repo,
630648
issue_number: context.payload.issue.number,
631-
body: `❌ Failed to update branch with latest changes from \`${baseBranch}\`.
632-
633-
This usually means there are merge conflicts that need to be resolved manually.
634-
635-
Please update your branch locally:
636-
\`\`\`bash
637-
git fetch origin ${baseBranch}
638-
git merge origin/${baseBranch}
639-
# Resolve conflicts
640-
git push
641-
\`\`\``
649+
body: failureMessage
642650
});
643651
644652
// Add -1 reaction to original comment

0 commit comments

Comments
 (0)