Skip to content

Commit 893e952

Browse files
authored
Merge pull request #87 from mongoKart/add-action
Add action for staging links
2 parents 63a2e93 + fc45962 commit 893e952

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

.github/pull_request_template.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Pull Request Info
2+
3+
[PR Reviewing Guidelines](https://github.com/mongodb/docs-golang/blob/master/REVIEWING.md)
4+
5+
JIRA - <https://jira.mongodb.org/browse/DOCSP-NNNNN>
6+
7+
### Staging Links
8+
9+
<!-- start insert-links --><!-- end insert-links -->
10+
11+
## Self-Review Checklist
12+
13+
- [ ] Is this free of any warnings or errors in the RST?
14+
- [ ] Did you run a spell-check?
15+
- [ ] Did you run a grammar-check?
16+
- [ ] Are all the links working?
17+
- [ ] Are the [facets and meta keywords](https://wiki.corp.mongodb.com/display/DE/Docs+Taxonomy) accurate?
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Add Netlify Links To Changed Pages
2+
on:
3+
workflow_call:
4+
pull_request_target:
5+
jobs:
6+
get-pr-changes:
7+
name: Get Changed Files & Update PR Description
8+
runs-on: ubuntu-latest
9+
permissions:
10+
issues: write
11+
contents: write
12+
pull-requests: write
13+
repository-projects: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Get Changed Files
17+
id: changed-files
18+
# pin to a specific commit to ensure stability
19+
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c
20+
with:
21+
separator: ","
22+
files: source/**
23+
- name: Build Netlify Links for Changed Pages
24+
id: build_page_links
25+
env:
26+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
27+
run: |
28+
new_links=""
29+
base_link='https://deploy-preview-${{ github.event.number }}--mongodb-docs-ruby.netlify.app'
30+
files=$(echo "$CHANGED_FILES" | tr "," "\n")
31+
for file in $files; do
32+
echo "processing ${file}"
33+
if (! grep -s "includes/" <<< "$file") &&
34+
(! grep -s "images/" <<< "$file") &&
35+
(! grep -s "examples/" <<< "$file"); then
36+
file="${file#source}"
37+
file="${file%.txt}"
38+
filenoslash="${file:1}"
39+
echo "${base_link}${file}"
40+
new_links+="<li><a href=${base_link}${file}>${filenoslash}</a></li>"
41+
else
42+
echo "(file skipped)"
43+
fi
44+
done
45+
if [ "$new_links" == "" ]; then
46+
new_links="No pages to preview"
47+
fi
48+
echo "Final new_links string: "
49+
echo "${new_links}"
50+
echo "staging_links=${new_links}" >> "$GITHUB_OUTPUT"
51+
- name: Update the PR Description
52+
uses: MongoCaleb/pr-description-action@master
53+
with:
54+
regex: "<!-- start insert-links -->.*<!-- end insert-links -->"
55+
appendContentOnMatchOnly: true
56+
regexFlags: is
57+
content: "<!-- start insert-links -->\n${{ steps.build_page_links.outputs.staging_links }}\n<!-- end insert-links -->"
58+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)