Skip to content

Commit 9718ae9

Browse files
committed
ci: docpreview: add new job to handle doc previews
Add a new job that takes care of posting documentation preview information, including: - Link to preview site - List of links to edited files, easing the review process Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 4d4bf1c commit 9718ae9

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/docpreview.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Documentation Preview
2+
3+
on:
4+
pull_request_target:
5+
paths:
6+
- '.github/workflows/docbuild.yml'
7+
- '**.rst'
8+
- '**/Kconfig'
9+
- '**/sample.yaml'
10+
- 'doc/**'
11+
- 'applications/**'
12+
- 'include/**'
13+
- 'lib/**'
14+
- 'doc/requirements.txt'
15+
- 'scripts/tools-versions-*.yml'
16+
- 'west.yml'
17+
18+
jobs:
19+
doc-preview:
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.event.pull_request.head.sha }}
26+
fetch-depth: 0
27+
persist-credentials: false
28+
29+
- name: Find nRF Connect SDK Edited Documents
30+
id: nrf-edited-documents
31+
run: |
32+
PREFIX="${{ vars.NCS_DOC_HOSTING_URL }}PR-${{ github.event.pull_request.number }}/"
33+
CHANGED=$(git diff --name-only --diff-filter=d "${{ github.event.pull_request.base.sha }}..HEAD")
34+
35+
NRF=$(echo "$CHANGED" | \
36+
grep -e "doc/nrf/" | \
37+
grep -e ".rst" | \
38+
sed -e "s#^doc/nrf\(.*\)\.rst#${PREFIX}nrf\1.html#g")
39+
40+
NRF_EXT=$(echo "$CHANGED" | \
41+
grep -e "applications/" -e "samples/" -e "scripts/" -e "tests/" | \
42+
grep -e ".rst" | \
43+
sed -e "s#^\(applications\|samples\|scripts\|tests\)\(.*\)\.rst#${PREFIX}nrf\/\1\2.html#g")
44+
45+
NRF_ALL=$(printf "$NRF\n$NRF_EXT")
46+
47+
if [ ! -z "$NRF_ALL" ]; then
48+
COMMENT=$(printf "\nPreview links for modified nRF Connect SDK documents:\n\n$NRF_ALL")
49+
50+
echo "COMMENT<<EOF" >> $GITHUB_OUTPUT
51+
echo "$COMMENT" >> $GITHUB_OUTPUT
52+
echo "EOF" >> $GITHUB_OUTPUT
53+
fi
54+
55+
- name: Find Comment
56+
uses: peter-evans/find-comment@v3
57+
id: fc
58+
with:
59+
issue-number: ${{ github.event.pull_request.number }}
60+
comment-author: 'github-actions[bot]'
61+
body-includes: documentation preview
62+
63+
- name: Create or update comment
64+
uses: peter-evans/create-or-update-comment@v4
65+
with:
66+
comment-id: ${{ steps.fc.outputs.comment-id }}
67+
issue-number: ${{ github.event.pull_request.number }}
68+
body: |
69+
After documentation is built, you will find the preview for this PR [here](${{ vars.NCS_DOC_HOSTING_URL }}PR-${{ github.event.pull_request.number }}).
70+
${{ steps.nrf-edited-documents.outputs.COMMENT }}
71+
edit-mode: replace

0 commit comments

Comments
 (0)