Skip to content
Merged
Changes from 2 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
15 changes: 8 additions & 7 deletions .github/workflows/preview_comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ jobs:
file_limit=100
build_url="https://ez-systems-developer-documentation--${{ github.event.pull_request.number }}.com.readthedocs.build/${{inputs.project}}en/${{ github.event.pull_request.number }}/"

change_list=$(git diff --name-only HEAD "origin/$GITHUB_BASE_REF" | grep -E "^docs\/.*\.md$" | sed -E "s|^docs/(.*)\.md$|- [docs/\1.md](${build_url}\1/)|")
change_count=$(echo "$change_list" | wc -l)
md_change_list=$(git diff --name-only HEAD "origin/$GITHUB_BASE_REF" -- docs/ | grep -E "^docs\/.*\.md$" | sed -E "s|^docs/(.*)\.md$|- [docs/\1.md](${build_url}\1/)|")
par_change_list=$(git diff --name-only HEAD "origin/$GITHUB_BASE_REF" -- docs/api/php_api/php_api_reference/ | grep -E "^docs\/.*\.html$" | sed -E "s|^docs/(.*\.html)$|- [docs/\1](${build_url}\1)|")
change_count=$(( $(echo "$md_change_list" | wc -l) + $(echo "$par_change_list" | wc -l) ))

if [[ $change_list -eq '' ]] ; then
comment="Preview of modified Markdown: no Markdown change to preview."
if [[ "$md_change_list$par_change_list" -eq '' ]] ; then
comment="Preview of modified files: no change to preview."
elif [[ $change_count -gt $file_limit ]] ; then
comment="Preview of modified Markdown: Too many files modified in a single PR, preview link list is skipped. ($change_count files &gth; $file_limit)"
comment="Preview of modified files: Too many files modified in a single PR, preview link list is skipped. ($change_count files &gth; $file_limit)"
else
comment="Preview of modified Markdown:\n\n$change_list"
comment="# Preview of modified files\n\nPreview of modified Markdown:\n\n$md_change_list\n\nPreview of modified PHP API Reference:\n\n$par_change_list"
fi

echo -e "$comment" > comment.md
Expand All @@ -49,7 +50,7 @@ jobs:
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Preview of modified Markdown'
body-includes: 'Preview of modified files'

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
Expand Down