Skip to content

Conversation

@nathro
Copy link
Collaborator

@nathro nathro commented Aug 6, 2025

Fix handling of multiline custom guidelines in the GitHub Action

  • Use GitHub Actions multiline output syntax for $GITHUB_OUTPUT (context<<EOF ... EOF) so CUSTOM_GUIDELINES values with newlines are preserved intact.
  • Keep the JSON shape produced by jq as { "custom_guidelines": <string> }, so downstream consumers remain unchanged.
  • Maintain the existing fallback to {} when CUSTOM_GUIDELINES is unset.

Impact

  • Prevents truncation and newline corruption when passing multiline guidelines between steps.
  • Backwards-compatible; no breaking changes.

🤖 This description was generated automatically. Please react with 👍 if it's helpful or 👎 if it needs improvement.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Reviewed the change to support multiline custom guidelines. Great move switching to the multi-line $GITHUB_OUTPUT block format — this will prevent issues with newlines.

I have one small, high-confidence improvement suggestion to make this even safer and more robust.


🤖 Automated review complete. Please react with 👍 or 👎 on the individual review comments to provide feedback on their usefulness.

if [ -n "$CUSTOM_GUIDELINES" ]; then
echo "context=$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}')" >> $GITHUB_OUTPUT
echo 'context<<EOF' >> $GITHUB_OUTPUT
echo "$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}')" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice switch to the multi-line output format. To further harden this and avoid any quoting/command-substitution pitfalls, consider:

  1. Avoiding command substitution so you don’t lose trailing newlines and to keep very long outputs safe
  2. Quoting $GITHUB_OUTPUT in case the path ever contains spaces
  3. Using a slightly more unique delimiter than EOF

Example rewrite:

{
  {
    echo 'context<<GH_EOF'
    jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}'
    echo 'GH_EOF'
  } >> "$GITHUB_OUTPUT"
}

This writes jq’s output directly without $(...), keeps formatting intact, and quotes the output file path.

@nathro nathro merged commit 96c2e7c into main Aug 6, 2025
3 checks passed
@nathro nathro deleted the nathro_support_multiline_custom_guidelines branch August 12, 2025 03:42
@github-actions github-actions bot mentioned this pull request Sep 6, 2025
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.

2 participants