-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix YAML syntax error in workflow file #11275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix YAML syntax error in workflow file #11275
Conversation
Replace JavaScript template literals with string concatenation to avoid YAML parser confusion with template literal interpolation syntax. GitHub Actions YAML parser can misinterpret template literal dollar-brace syntax as expression delimiters.
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Branch Targeting SuggestionYou've targeted the
If This is an automated suggestion to help route contributions to the appropriate branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level Suggestion
To improve readability and maintainability, extract the inline JavaScript from the YAML workflow into a separate .js file. This avoids syntax conflicts and makes the script easier to manage. [High-level, importance: 8]
Solution Walkthrough:
Before:
# in .github/workflows/pg-version-check.yml
- name: Post comment if issues found
if: steps.pg_check.outputs.exit_code == '1'
uses: actions/github-script@v7
with:
script: |
const output = '${{ steps.pg_check.outputs.output }}';
let issuesContent = '...';
// ... logic to parse issues ...
const commentBody = '## ⚠️ Parameter Group Version Check\n\n' +
'The following parameter groups may need version increments:\n\n' +
issuesContent + '\n\n' +
'**Why this matters:**\n' +
'...';
// ... logic to post comment ...
After:
# in .github/workflows/pg-version-check.yml
- name: Post comment if issues found
if: steps.pg_check.outputs.exit_code == '1'
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/scripts/post-comment.js');
await script({
github,
context,
output: `${{ steps.pg_check.outputs.output }}`
});
# in a new file .github/scripts/post-comment.js
module.exports = async ({ github, context, output }) => {
let issuesContent = '...';
// ... logic to parse issues from `output` ...
const commentBody = `## ⚠️ Parameter Group Version Check
The following parameter groups may need version increments:
${issuesContent}
**Why this matters:**
...`;
// ... logic to post comment ...
};
| *This is an automated check. False positives are possible. If you believe the version increment is not needed, please explain in a comment.*`; | ||
| const commentBody = '## ⚠️ Parameter Group Version Check\n\n' + | ||
| 'The following parameter groups may need version increments:\n\n' + | ||
| issuesContent + '\n\n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Wrap the issuesContent variable in a fenced code block to prevent unintended markdown formatting in the final comment. [general, importance: 6]
| issuesContent + '\n\n' + | |
| '```\n' + issuesContent + '\n```\n\n' + |
| const output = '${{ steps.pg_check.outputs.output }}'; | ||
| let issuesContent = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add a size/emptiness guard for output (GitHub comments have limits and step outputs can be empty/huge) and truncate or fall back before parsing/using it. [Learned best practice, importance: 6]
| const output = '${{ steps.pg_check.outputs.output }}'; | |
| let issuesContent = ''; | |
| const rawOutput = '${{ steps.pg_check.outputs.output }}'; | |
| const MAX_OUTPUT_CHARS = 60000; // keep below GitHub comment limits | |
| const output = (rawOutput ?? '').toString().slice(0, MAX_OUTPUT_CHARS); | |
| let issuesContent = output.length ? '' : '*No output captured from pg_check step*'; |
User description
Replace JavaScript template literals with string concatenation to avoid YAML parser confusion with template literal interpolation syntax. GitHub Actions YAML parser can misinterpret template literal dollar-brace syntax as expression delimiters.
PR Type
Bug fix
Description
Replace template literals with string concatenation in GitHub Actions workflow
Avoid YAML parser confusion with template literal dollar-brace syntax
Fix expression delimiter misinterpretation in workflow script
Diagram Walkthrough
File Walkthrough
pg-version-check.yml
Replace template literals with string concatenation.github/workflows/pg-version-check.yml
outputvariablecommentBodyvariable