Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ runs:
shell: bash
run: |
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.

echo 'EOF' >> $GITHUB_OUTPUT
else
echo "context={}" >> $GITHUB_OUTPUT
fi
Expand Down