From d75611239874744233468235d37e6858f9500778 Mon Sep 17 00:00:00 2001 From: Konrad Grucel Date: Wed, 25 Mar 2026 11:38:19 +0100 Subject: [PATCH] docs: Integrate Aliro docs with Zoomin - Add doc_build.yml workflow for building docs, preparing Azure and Zoomin upload artifacts. - Add doc_publish.yml workflow for publishing docs to Azure Storage and Zoomin using SFTP. - Add doc_remove.yml workflow for cleaning up PR preview docs from Azure Storage. - Add _zoomin/aliro.custom.properties and _zoomin/aliro.tags.yml for Zoomin metadata. Signed-off-by: Konrad Grucel --- .github/workflows/doc_build.yml | 111 +++++++++++++++++++++++++++ .github/workflows/doc_publish.yml | 99 ++++++++++++++++++++++++ .github/workflows/doc_remove.yml | 20 +++++ docs/_zoomin/aliro.custom.properties | 2 + docs/_zoomin/aliro.tags.yml | 10 +++ 5 files changed, 242 insertions(+) create mode 100644 .github/workflows/doc_build.yml create mode 100644 .github/workflows/doc_publish.yml create mode 100644 .github/workflows/doc_remove.yml create mode 100644 docs/_zoomin/aliro.custom.properties create mode 100644 docs/_zoomin/aliro.tags.yml diff --git a/.github/workflows/doc_build.yml b/.github/workflows/doc_build.yml new file mode 100644 index 00000000..35883d9d --- /dev/null +++ b/.github/workflows/doc_build.yml @@ -0,0 +1,111 @@ +name: Documentation Build + +permissions: + contents: read + +on: + pull_request: + types: [opened, synchronize, reopened] + branches: + - main + paths: + - '.github/workflows/doc_build.yml' + - '**.rst' + - 'docs/**' + push: + branches: + - main + tags: + - v* + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Set up Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: 3.12 + cache: pip + cache-dependency-path: docs/requirements.txt + pip-install: | + -r docs/requirements.txt + + - name: Build + working-directory: docs + run: make html + + - name: Check version + run: | + VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$" + if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then + VERSION=${BASH_REMATCH[1]} + elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then + VERSION="latest" + elif [[ "${{ github.event_name }}" == "pull_request" ]]; then + VERSION="pr-${{ github.event.number }}" + fi + echo "VERSION=${VERSION}" + echo "VERSION=${VERSION}" >> "$GITHUB_ENV" + + - name: Prepare Azure upload + run: | + PUBLISH="$PWD/publish" + mkdir -p "$PUBLISH" + + MONITOR="monitor_${{ github.run_id }}.txt" + + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + ARCHIVE="legacy-addon-aliro-pr-${{ github.event.number }}.zip" + echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}" + echo "${{ github.event.number }}" > pr.txt + else + ARCHIVE="legacy-addon-aliro-${VERSION}.zip" + echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}" + fi + + pushd "docs/build/html" + zip -rq "${ARCHIVE}" . + mv "${ARCHIVE}" "$PUBLISH" + popd + + mv "${MONITOR}" "$PUBLISH" + if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi + + - name: Prepare Zoomin upload + if: ${{ github.event_name == 'push' }} + run: | + PUBLISH="$PWD/publish" + mkdir -p "$PUBLISH" + + OUTDIR=docs/build/html + ARCHIVE="addon-aliro_$VERSION.zip" + + cp docs/_zoomin/aliro.custom.properties "$OUTDIR/custom.properties" + sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties" + + cp docs/_zoomin/aliro.tags.yml "$OUTDIR/tags.yml" + sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml" + + pushd "$OUTDIR" + zip -rq "$ARCHIVE" . + mv "$ARCHIVE" "$PUBLISH" + popd + + - 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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: docs + retention-days: 5 + path: | + publish/* diff --git a/.github/workflows/doc_publish.yml b/.github/workflows/doc_publish.yml new file mode 100644 index 00000000..92a34b98 --- /dev/null +++ b/.github/workflows/doc_publish.yml @@ -0,0 +1,99 @@ +name: Documentation Publish + +permissions: + contents: 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: 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 legacy-addon-aliro*.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 }}addon-aliro?$NCS_DOC_SAS_PRS" --recursive=true + else + azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addon-aliro?$NCS_DOC_SAS_MAIN" --recursive=true + fi + + - name: Upload Zoomin documentation + if: > + github.event.workflow_run.head_branch == 'main' && + github.event.workflow_run.head_repository.full_name == github.repository + env: + NCS_ZOOMIN_KEY: ${{ secrets.NCS_ZOOMIN_KEY }} + run: | + # trust server + mkdir -p ~/.ssh + ssh-keyscan ${{ vars.NCS_ZOOMIN_SERVER }} >> ~/.ssh/known_hosts + + # prepare key + touch zoomin_key + chmod 600 zoomin_key + echo "$NCS_ZOOMIN_KEY" | base64 -d > zoomin_key + + # upload files + for file in docs/addon-aliro*.zip; do + sftp -v -i zoomin_key ${{ vars.NCS_ZOOMIN_USER }}@${{ vars.NCS_ZOOMIN_SERVER }} <