Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: doc: post preview comment after build finishes #20610

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/docbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
steps:
- name: Checkout sources
uses: nrfconnect/action-checkout-west-update@main
with:
git-fetch-depth: 0

- name: cache-pip
uses: actions/cache@v4
Expand Down Expand Up @@ -178,6 +180,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="https://ncsdoc.z6.web.core.windows.net/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 +215,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