diff --git a/.github/workflows/docbuild.yml b/.github/workflows/docbuild.yml index b999ce7a122..10bcc9b35a7 100644 --- a/.github/workflows/docbuild.yml +++ b/.github/workflows/docbuild.yml @@ -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 @@ -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="${{ 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 @@ -187,3 +215,4 @@ jobs: ncs/nrf/*.zip ncs/nrf/monitor*.txt ncs/nrf/pr.txt + ncs/nrf/comment.txt diff --git a/.github/workflows/docpreview.yml b/.github/workflows/docpreview.yml deleted file mode 100644 index 89048fae113..00000000000 --- a/.github/workflows/docpreview.yml +++ /dev/null @@ -1,71 +0,0 @@ -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<> $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: preview for this PR - - - 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 diff --git a/.github/workflows/docpublish.yml b/.github/workflows/docpublish.yml index cb082b8dac9..228b14664ce 100644 --- a/.github/workflows/docpublish.yml +++ b/.github/workflows/docpublish.yml @@ -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: @@ -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