fix: extract decorate-pr comment rendering from action yaml
This commit is contained in:
@@ -328,37 +328,6 @@ runs:
|
||||
echo "$failure_reason" >&2
|
||||
exit 1
|
||||
fi
|
||||
- name: Extract changelog unreleased entries
|
||||
id: extract-changelog
|
||||
shell: bash
|
||||
env:
|
||||
CHANGELOG: ${{ inputs.changelog }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ ! -f "$CHANGELOG" ]]; then
|
||||
printf 'unreleased_entries=%s\n' "" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Extract everything between [Unreleased] header and the next [X.Y.Z] header
|
||||
unreleased="$(awk '
|
||||
/^## \[Unreleased\]/ { in_unreleased=1; next }
|
||||
/^## \[[0-9]+\.[0-9]+\.[0-9]+\]/ { if (in_unreleased) exit }
|
||||
in_unreleased && NF { print }
|
||||
' "$CHANGELOG")"
|
||||
|
||||
# Use a temporary file to handle multiline content
|
||||
tmp_file=$(mktemp)
|
||||
printf '%s' "$unreleased" > "$tmp_file"
|
||||
|
||||
# Read it back and set as output
|
||||
delimiter="EOF_CHANGELOG"
|
||||
printf '%s<<%s\n' "unreleased_entries<<$delimiter" "$delimiter" >> "$GITHUB_OUTPUT"
|
||||
cat "$tmp_file" >> "$GITHUB_OUTPUT"
|
||||
printf '%s\n' "$delimiter" >> "$GITHUB_OUTPUT"
|
||||
|
||||
rm -f "$tmp_file"
|
||||
|
||||
- name: Build PR comment markdown
|
||||
id: build-comment
|
||||
@@ -373,102 +342,11 @@ runs:
|
||||
GATE_MODE: ${{ inputs.changelog-gate-mode }}
|
||||
DOCS_ONLY: ${{ steps.changelog-gate.outputs.docs_only }}
|
||||
ADDITIONS_COUNT: ${{ steps.changelog-gate.outputs.unreleased_additions_count }}
|
||||
FAILURE_REASON: ${{ steps.changelog-gate.outputs.gate_failure_reason }}
|
||||
FAILURE_REASON: ${{ steps.changelog-gate.outputs.failure_reason }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# Start building the comment
|
||||
tmp_file=$(mktemp)
|
||||
|
||||
# Add title and coverage section
|
||||
cat > "$tmp_file" << 'EOF'
|
||||
<!-- vociferate-pr-review -->
|
||||
EOF
|
||||
|
||||
printf '## %s\n\n' "$COMMENT_TITLE" >> "$tmp_file"
|
||||
|
||||
# Coverage badge section
|
||||
cat >> "$tmp_file" << EOF
|
||||
### Coverage
|
||||

|
||||
|
||||
**Coverage:** $COVERAGE_PCT%
|
||||
|
||||
EOF
|
||||
|
||||
# Changelog gate section (if enabled)
|
||||
if [[ "$GATE_ENABLED" == "true" ]]; then
|
||||
gate_status="✓ Pass"
|
||||
if [[ "$GATE_PASSED" != "true" ]]; then
|
||||
if [[ "$GATE_MODE" == "strict" ]]; then
|
||||
gate_status="✗ Fail"
|
||||
else
|
||||
gate_status="⚠ Warning"
|
||||
fi
|
||||
fi
|
||||
|
||||
cat >> "$tmp_file" << EOF
|
||||
|
||||
### Changelog Gate
|
||||
**Status:** $gate_status
|
||||
|
||||
EOF
|
||||
|
||||
if [[ "$DOCS_ONLY" == "true" ]]; then
|
||||
cat >> "$tmp_file" << 'EOF'
|
||||
This PR only modifies documentation—changelog entry not required.
|
||||
|
||||
EOF
|
||||
elif [[ "$GATE_PASSED" == "true" ]]; then
|
||||
cat >> "$tmp_file" << EOF
|
||||
Found $ADDITIONS_COUNT line(s) added to Unreleased section ✓
|
||||
|
||||
EOF
|
||||
else
|
||||
cat >> "$tmp_file" << EOF
|
||||
**Issue:** $FAILURE_REASON
|
||||
|
||||
**How to fix:** Add an entry under the appropriate subsection in the \`## [Unreleased]\` section of \`CHANGELOG.md\`. Use one of:
|
||||
- \`### Breaking\` for backwards-incompatible changes
|
||||
- \`### Added\` for new features
|
||||
- \`### Changed\` for behavior changes
|
||||
- \`### Removed\` for deprecated removals
|
||||
- \`### Fixed\` for bug fixes
|
||||
|
||||
Example:
|
||||
\`\`\`markdown
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- New changelog gate validation for PR decoration.
|
||||
\`\`\`
|
||||
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
# Changelog section
|
||||
if [[ -n "$UNRELEASED" ]]; then
|
||||
cat >> "$tmp_file" << 'EOF'
|
||||
### Unreleased Changes
|
||||
|
||||
EOF
|
||||
printf '%s\n' "$UNRELEASED" >> "$tmp_file"
|
||||
printf '\n' >> "$tmp_file"
|
||||
fi
|
||||
|
||||
# Add footer
|
||||
cat >> "$tmp_file" << 'EOF'
|
||||
---
|
||||
*This comment was automatically generated by [vociferate/decorate-pr](https://git.hrafn.xyz/aether/vociferate).*
|
||||
EOF
|
||||
|
||||
# Store as output using delimiter
|
||||
delimiter="EOF_COMMENT"
|
||||
printf '%s<<%s\n' "comment_body<<$delimiter" "$delimiter" >> "$GITHUB_OUTPUT"
|
||||
cat "$tmp_file" >> "$GITHUB_OUTPUT"
|
||||
printf '%s\n' "$delimiter" >> "$GITHUB_OUTPUT"
|
||||
|
||||
rm -f "$tmp_file"
|
||||
bash "$GITHUB_ACTION_PATH/build-comment.sh"
|
||||
|
||||
- name: Find and update/post PR comment
|
||||
id: post-comment
|
||||
|
||||
Reference in New Issue
Block a user