Skip to content

Commit

Permalink
ci: doc: post preview comment after build finishes
Browse files Browse the repository at this point in the history
As of today, preview comment was published just after PR is posted,
so if e.g. build fails, the comment may be misleading. Update the CI
jobs to perform this in 2 steps, so that the docpublish workflow takes
care of posting the comment.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull committed Feb 26, 2025
1 parent 444b6e0 commit a152838
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 71 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/docbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ jobs:
zip -rq "$ARCHIVE" .
mv "$ARCHIVE" "$ROOT"
popd
- name: Find nRF Connect SDK Edited Documents
working-directory: ncs/nrf
run: |
COMMENT="comment.txt"
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")
echo "You can find the documentation preview for this PR [here](${PREFIX})." >> $COMMENT
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
printf "\nPreview links for modified nRF Connect SDK documents:\n\n$NRF_ALL" >> $COMMENT
fi
- name: Store
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
uses: actions/upload-artifact@v4
Expand All @@ -187,3 +213,4 @@ jobs:
ncs/nrf/*.zip
ncs/nrf/monitor*.txt
ncs/nrf/pr.txt
ncs/nrf/comment.txt
71 changes: 0 additions & 71 deletions .github/workflows/docpreview.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/docpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
echo "OUTDIR=$OUTDIR" >> "$GITHUB_ENV"
unzip legacy-ncs*.zip -d $OUTDIR
- name: Obtain PR number
working-directory: docs
run: |
echo "PR=$(cat pr.txt)" >> "$GITHUB_ENV"
- name: Upload to Azure storage
working-directory: docs
env:
Expand Down Expand Up @@ -68,3 +73,19 @@ jobs:
quit
EOF
done
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ env.PR }}
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: ${{ env.PR }}
body-path: docs/comment.txt
edit-mode: replace

0 comments on commit a152838

Please sign in to comment.