|
| 1 | +name: Documentation Publish |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + pull-requests: write |
| 6 | + |
| 7 | +on: |
| 8 | + |
| 9 | + workflow_run: |
| 10 | + workflows: ["Documentation Build"] |
| 11 | + types: |
| 12 | + - completed |
| 13 | + |
| 14 | +jobs: |
| 15 | + publish: |
| 16 | + runs-on: ubuntu-24.04 |
| 17 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 18 | + steps: |
| 19 | + - name: Download artifacts |
| 20 | + uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 |
| 21 | + with: |
| 22 | + workflow: doc_build.yml |
| 23 | + run_id: ${{ github.event.workflow_run.id }} |
| 24 | + |
| 25 | + - name: Unzip html archive |
| 26 | + working-directory: docs |
| 27 | + run: | |
| 28 | + OUTDIR=$(awk 'NR==1 { if ($3 ~ /^(latest|PR-[0-9]+|[0-9]+\.[0-9a-zA-Z\.\-]+)$/) print $3 }' monitor_*.txt) |
| 29 | + echo "OUTDIR=$OUTDIR" >> "$GITHUB_ENV" |
| 30 | + unzip legacy-addon-aliro*.zip -d $OUTDIR |
| 31 | + find "$OUTDIR" -type l -delete |
| 32 | +
|
| 33 | + - name: Obtain PR number |
| 34 | + if: ${{ github.event.workflow_run.event == 'pull_request' }} |
| 35 | + working-directory: docs |
| 36 | + run: | |
| 37 | + if [ -f pr.txt ]; then |
| 38 | + PR=$(head -n 1 pr.txt | tr -cd '0-9') |
| 39 | + fi |
| 40 | + printf 'PR=%s\n' "$PR" >> "$GITHUB_ENV" |
| 41 | +
|
| 42 | + - name: Upload to Azure storage |
| 43 | + working-directory: docs |
| 44 | + env: |
| 45 | + AZCOPY_CONCURRENCY_VALUE: 1024 |
| 46 | + NCS_DOC_SAS_PRS: ${{ secrets.NCS_DOC_SAS_PRS }} |
| 47 | + NCS_DOC_SAS_MAIN: ${{ secrets.NCS_DOC_SAS_MAIN }} |
| 48 | + run: | |
| 49 | + if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then |
| 50 | + azcopy cp $OUTDIR "${{ vars.NCS_DOC_PR_STORAGE_URL }}addon-aliro?$NCS_DOC_SAS_PRS" --recursive=true |
| 51 | + else |
| 52 | + azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addon-aliro?$NCS_DOC_SAS_MAIN" --recursive=true |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Upload Zoomin documentation |
| 56 | + if: > |
| 57 | + github.event.workflow_run.head_branch == 'main' && |
| 58 | + github.event.workflow_run.head_repository.full_name == github.repository |
| 59 | + env: |
| 60 | + NCS_ZOOMIN_KEY: ${{ secrets.NCS_ZOOMIN_KEY }} |
| 61 | + run: | |
| 62 | + # trust server |
| 63 | + mkdir -p ~/.ssh |
| 64 | + ssh-keyscan ${{ vars.NCS_ZOOMIN_SERVER }} >> ~/.ssh/known_hosts |
| 65 | +
|
| 66 | + # prepare key |
| 67 | + touch zoomin_key |
| 68 | + chmod 600 zoomin_key |
| 69 | + echo "$NCS_ZOOMIN_KEY" | base64 -d > zoomin_key |
| 70 | +
|
| 71 | + # upload files |
| 72 | + for file in docs/addon-aliro*.zip; do |
| 73 | + sftp -v -i zoomin_key ${{ vars.NCS_ZOOMIN_USER }}@${{ vars.NCS_ZOOMIN_SERVER }} <<EOF |
| 74 | + cd docs-be.nordicsemi.com/sphinx-html/incoming |
| 75 | + put ${file} |
| 76 | + cd ../../../nordic-be-dev.zoominsoftware.io/sphinx-html/incoming |
| 77 | + put ${file} |
| 78 | + quit |
| 79 | + EOF |
| 80 | + done |
| 81 | +
|
| 82 | + - name: Find Comment |
| 83 | + if: ${{ github.event.workflow_run.event == 'pull_request' }} |
| 84 | + uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3 |
| 85 | + id: fc |
| 86 | + with: |
| 87 | + issue-number: ${{ env.PR }} |
| 88 | + comment-author: 'github-actions[bot]' |
| 89 | + body-includes: documentation preview |
| 90 | + |
| 91 | + - name: Create or update comment |
| 92 | + if: ${{ github.event.workflow_run.event == 'pull_request' }} |
| 93 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 |
| 94 | + with: |
| 95 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 96 | + issue-number: ${{ env.PR }} |
| 97 | + body: | |
| 98 | + You can find the documentation preview for this PR [here](${{ vars.NCS_DOC_PR_HOSTING_URL }}addon-aliro/PR-${{ env.PR }}/). |
| 99 | + edit-mode: replace |
0 commit comments