File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ name : " Post preview links for changed files"
2+
3+ on :
4+ pull_request : ~
5+ workflow_call :
6+ inputs :
7+ project :
8+ description : ' The project to build (dev doc, user doc)'
9+ default : ' '
10+ required : false
11+ type : string
12+
13+ jobs :
14+ post-preview-links :
15+ name : Post preview links for changed files
16+ runs-on : ubuntu-latest
17+ permissions :
18+ # Needed to manage the comment
19+ pull-requests : write
20+
21+ steps :
22+ - uses : actions/checkout@v4
23+ with :
24+ fetch-depth : 0
25+
26+ - name : Create comment for changed files
27+ run : |
28+ file_limit=100
29+ build_url="https://ez-systems-developer-documentation--${{ github.event.pull_request.number }}.com.readthedocs.build/${{inputs.project}}en/${{ github.event.pull_request.number }}/"
30+
31+ 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/)|")
32+ change_count=$(echo "$change_list" | wc -l)
33+
34+ if [[ $change_list -eq '' ]] ; then
35+ comment="Preview of modified Markdown: no Markdown change to preview."
36+ elif [[ $change_count -gt $file_limit ]] ; then
37+ comment="Preview of modified Markdown: Too many files modified in a single PR, preview link list is skipped. ($change_count files >h; $file_limit)"
38+ else
39+ comment="Preview of modified Markdown:\n\n$change_list"
40+ fi
41+
42+ echo -e "$comment" > comment.md
43+
44+ - name : Find comment
45+ id : find-comment
46+ uses : peter-evans/find-comment@v3
47+ with :
48+ issue-number : ${{ github.event.pull_request.number }}
49+ comment-author : ' github-actions[bot]'
50+ body-includes : ' Preview of modified Markdown'
51+
52+ - name : Create or update comment
53+ uses : peter-evans/create-or-update-comment@v4
54+ with :
55+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
56+ issue-number : ${{ github.event.pull_request.number }}
57+ body-path : comment.md
58+ edit-mode : replace
You can’t perform that action at this time.
0 commit comments