forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Documentation Preview | ||
|
||
on: | ||
pull_request_target: | ||
paths: | ||
- '.github/workflows/docbuild.yml' | ||
- '**.rst' | ||
- '**/Kconfig' | ||
- '**/sample.yaml' | ||
- 'doc/**' | ||
- 'applications/**' | ||
- 'include/**' | ||
- 'lib/**' | ||
- 'doc/requirements.txt' | ||
- 'scripts/tools-versions-*.yml' | ||
- 'west.yml' | ||
|
||
jobs: | ||
doc-preview: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Find nRF Connect SDK Edited Documents | ||
id: nrf-edited-documents | ||
run: | | ||
PREFIX="${{ vars.NCS_DOC_HOSTING_URL }}PR-${{ github.event.pull_request.number }}/" | ||
CHANGED=$(git diff --name-only --diff-filter=d "${{ github.event.pull_request.base.sha }}..HEAD") | ||
NRF=$(echo "$CHANGED" | \ | ||
grep -e "doc/nrf/" | \ | ||
grep -e ".rst" | \ | ||
sed -e "s#^doc/nrf\(.*\)\.rst#${PREFIX}nrf\1.html#g") | ||
NRF_EXT=$(echo "$CHANGED" | \ | ||
grep -e "applications/" -e "samples/" -e "scripts/" -e "tests/" | \ | ||
grep -e ".rst" | \ | ||
sed -e "s#^\(applications\|samples\|scripts\|tests\)\(.*\)\.rst#${PREFIX}nrf\/\1\2.html#g") | ||
NRF_ALL=$(printf "$NRF\n$NRF_EXT") | ||
if [ ! -z "$NRF_ALL" ]; then | ||
COMMENT=$(printf "\nPreview links for modified nRF Connect SDK documents:\n\n$NRF_ALL") | ||
echo "COMMENT<<EOF" >> $GITHUB_OUTPUT | ||
echo "$COMMENT" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Find Comment | ||
uses: peter-evans/find-comment@v3 | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: documentation preview | ||
|
||
- name: Create or update comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
After documentation is built, you will find the preview for this PR [here](${{ vars.NCS_DOC_HOSTING_URL }}PR-${{ github.event.pull_request.number }}). | ||
${{ steps.nrf-edited-documents.outputs.COMMENT }} | ||
edit-mode: replace |