-
Notifications
You must be signed in to change notification settings - Fork 21
56 lines (56 loc) · 2.25 KB
/
add-netlify-links.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Add Netlify Links To Changed Pages
on:
workflow_call:
pull_request_target:
jobs:
get-pr-changes:
name: Get Changed Files & Update PR Description
runs-on: ubuntu-latest
permissions:
issues: write
contents: write
pull-requests: write
repository-projects: write
steps:
- uses: actions/checkout@v4
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v44
with:
separator: ","
files: source/**
- name: Build Netlify Links for Changed Pages
id: build_page_links
run: |
new_links=""
base_link='https://deploy-preview-${{ github.event.number }}--mongodb-docs-csharp.netlify.app'
changed_files=${{ steps.changed-files.outputs.all_changed_files }}
files=$(echo $changed_files | tr "," "\n")
for file in $files; do
echo "processing ${file}"
if (! grep -s "includes/" <<< $file) &&
(! grep -s "images/" <<< $file) &&
(! grep -s "examples/" <<< $file); then
file="${file#source}"
file="${file%.txt}"
filenoslash="${file:1}"
echo "${base_link}${file}"
new_links+="<li><a href=${base_link}${file}>${filenoslash}</a></li>"
else
echo "(file skipped)"
fi
done
if [ "$new_links" == "" ]; then
new_links="No pages to preview"
fi
echo "Final new_links string: "
echo "${new_links}"
echo "staging_links=${new_links}" >> "$GITHUB_OUTPUT"
- name: Update the PR Description
uses: MongoCaleb/pr-description-action@master
with:
regex: "<!-- start insert-links -->.*<!-- end insert-links -->"
appendContentOnMatchOnly: true
regexFlags: is
content: "<!-- start insert-links -->\n${{ steps.build_page_links.outputs.staging_links }}\n<!-- end insert-links -->"
token: ${{ secrets.GITHUB_TOKEN }}