Documentation Publish #1
This file contains hidden or 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
| name: Documentation Publish | |
| permissions: | |
| contents: read | |
| actions: read | |
| pull-requests: write | |
| on: | |
| workflow_run: | |
| workflows: ["Documentation Build"] | |
| types: | |
| - completed | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-24.04 | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| sparse-checkout: .github | |
| - name: Load doc add-on config | |
| uses: ./.github/actions/load-doc-config | |
| - name: Download artifacts | |
| uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 | |
| with: | |
| workflow: doc_build.yml | |
| run_id: ${{ github.event.workflow_run.id }} | |
| - name: Unzip html archive | |
| working-directory: docs | |
| run: | | |
| OUTDIR=$(awk 'NR==1 { if ($3 ~ /^(latest|PR-[0-9]+|[0-9]+\.[0-9a-zA-Z\.\-]+)$/) print $3 }' monitor_*.txt) | |
| echo "OUTDIR=$OUTDIR" >> "$GITHUB_ENV" | |
| unzip ${{ env.DOC_ADDON_NAME }}*.zip -d $OUTDIR | |
| find "$OUTDIR" -type l -delete | |
| - name: Obtain PR number | |
| if: ${{ github.event.workflow_run.event == 'pull_request' }} | |
| working-directory: docs | |
| run: | | |
| if [ -f pr.txt ]; then | |
| PR=$(head -n 1 pr.txt | tr -cd '0-9') | |
| fi | |
| printf 'PR=%s\n' "$PR" >> "$GITHUB_ENV" | |
| - name: Upload to Azure storage | |
| working-directory: docs | |
| env: | |
| AZCOPY_CONCURRENCY_VALUE: 1024 | |
| NCS_DOC_SAS_PRS: ${{ secrets.NCS_DOC_SAS_PRS }} | |
| NCS_DOC_SAS_MAIN: ${{ secrets.NCS_DOC_SAS_MAIN }} | |
| run: | | |
| if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then | |
| azcopy cp $OUTDIR "${{ vars.NCS_DOC_PR_STORAGE_URL }}addons/${{ env.DOC_ADDON_NAME }}?$NCS_DOC_SAS_PRS" --recursive=true | |
| elif [[ "${{ github.event.workflow_run.head_repository.full_name }}" == "${{ github.repository }}" ]]; then | |
| azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addons/${{ env.DOC_ADDON_NAME }}?$NCS_DOC_SAS_MAIN" --recursive=true | |
| else | |
| echo "Skipping main-branch upload from untrusted repository: ${{ github.event.workflow_run.head_repository.full_name }}" | |
| fi | |
| - name: Find Comment | |
| if: ${{ github.event.workflow_run.event == 'pull_request' }} | |
| uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3 | |
| id: fc | |
| with: | |
| issue-number: ${{ env.PR }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: documentation preview | |
| - name: Create or update comment | |
| if: ${{ github.event.workflow_run.event == 'pull_request' }} | |
| uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 | |
| with: | |
| comment-id: ${{ steps.fc.outputs.comment-id }} | |
| issue-number: ${{ env.PR }} | |
| body-path: docs/comment.txt | |
| edit-mode: replace |