fix: extract decorate-pr comment rendering from action yaml
This commit is contained in:
71
decorate-pr/build-comment.sh
Normal file
71
decorate-pr/build-comment.sh
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
tmp_file=$(mktemp)
|
||||
trap 'rm -f "$tmp_file"' EXIT
|
||||
|
||||
{
|
||||
printf '%s\n' '<!-- vociferate-pr-review -->'
|
||||
printf '\n## %s\n\n' "$COMMENT_TITLE"
|
||||
printf '### Coverage\n'
|
||||
printf '\n\n' "$BADGE_URL"
|
||||
printf '**Coverage:** %s%%\n' "$COVERAGE_PCT"
|
||||
} > "$tmp_file"
|
||||
|
||||
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
|
||||
|
||||
{
|
||||
printf '\n### Changelog Gate\n'
|
||||
printf '**Status:** %s\n\n' "$gate_status"
|
||||
} >> "$tmp_file"
|
||||
|
||||
if [[ "$DOCS_ONLY" == "true" ]]; then
|
||||
printf '%s\n\n' 'This PR only modifies documentation; changelog entry not required.' >> "$tmp_file"
|
||||
elif [[ "$GATE_PASSED" == "true" ]]; then
|
||||
printf 'Found %s line(s) added to Unreleased section.\n\n' "$ADDITIONS_COUNT" >> "$tmp_file"
|
||||
else
|
||||
printf '**Issue:** %s\n\n' "$FAILURE_REASON" >> "$tmp_file"
|
||||
cat >> "$tmp_file" <<'EOF'
|
||||
**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
|
||||
|
||||
if [[ -n "$UNRELEASED" ]]; then
|
||||
{
|
||||
printf '### Unreleased Changes\n\n'
|
||||
printf '%s\n\n' "$UNRELEASED"
|
||||
} >> "$tmp_file"
|
||||
fi
|
||||
|
||||
cat >> "$tmp_file" <<'EOF'
|
||||
---
|
||||
*This comment was automatically generated by [vociferate/decorate-pr](https://git.hrafn.xyz/aether/vociferate).*
|
||||
EOF
|
||||
|
||||
delimiter="EOF_COMMENT"
|
||||
printf 'comment_body<<%s\n' "$delimiter" >> "$GITHUB_OUTPUT"
|
||||
cat "$tmp_file" >> "$GITHUB_OUTPUT"
|
||||
printf '%s\n' "$delimiter" >> "$GITHUB_OUTPUT"
|
||||
Reference in New Issue
Block a user