Skip to content

Commit 5f393db

Browse files
kg-nordicsemimarkaj-nordic
authored andcommitted
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 <konrad.grucel@nordicsemi.no>
1 parent ec0df88 commit 5f393db

5 files changed

Lines changed: 242 additions & 0 deletions

File tree

.github/workflows/doc_build.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Documentation Build
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
branches:
10+
- main
11+
paths:
12+
- '.github/workflows/doc_build.yml'
13+
- '**.rst'
14+
- 'docs/**'
15+
push:
16+
branches:
17+
- main
18+
tags:
19+
- v*
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-24.04
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
with:
32+
ref: ${{ github.event.pull_request.head.sha }}
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
36+
with:
37+
python-version: 3.12
38+
cache: pip
39+
cache-dependency-path: docs/requirements.txt
40+
pip-install: |
41+
-r docs/requirements.txt
42+
43+
- name: Build
44+
working-directory: docs
45+
run: make html
46+
47+
- name: Check version
48+
run: |
49+
VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$"
50+
if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then
51+
VERSION=${BASH_REMATCH[1]}
52+
elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then
53+
VERSION="latest"
54+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
55+
VERSION="pr-${{ github.event.number }}"
56+
fi
57+
echo "VERSION=${VERSION}"
58+
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
59+
60+
- name: Prepare Azure upload
61+
run: |
62+
PUBLISH="$PWD/publish"
63+
mkdir -p "$PUBLISH"
64+
65+
MONITOR="monitor_${{ github.run_id }}.txt"
66+
67+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
68+
ARCHIVE="legacy-addon-aliro-pr-${{ github.event.number }}.zip"
69+
echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}"
70+
echo "${{ github.event.number }}" > pr.txt
71+
else
72+
ARCHIVE="legacy-addon-aliro-${VERSION}.zip"
73+
echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}"
74+
fi
75+
76+
pushd "docs/build/html"
77+
zip -rq "${ARCHIVE}" .
78+
mv "${ARCHIVE}" "$PUBLISH"
79+
popd
80+
81+
mv "${MONITOR}" "$PUBLISH"
82+
if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi
83+
84+
- name: Prepare Zoomin upload
85+
if: ${{ github.event_name == 'push' }}
86+
run: |
87+
PUBLISH="$PWD/publish"
88+
mkdir -p "$PUBLISH"
89+
90+
OUTDIR=docs/build/html
91+
ARCHIVE="addon-aliro_$VERSION.zip"
92+
93+
cp docs/_zoomin/aliro.custom.properties "$OUTDIR/custom.properties"
94+
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties"
95+
96+
cp docs/_zoomin/aliro.tags.yml "$OUTDIR/tags.yml"
97+
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml"
98+
99+
pushd "$OUTDIR"
100+
zip -rq "$ARCHIVE" .
101+
mv "$ARCHIVE" "$PUBLISH"
102+
popd
103+
104+
- name: Store
105+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
106+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
107+
with:
108+
name: docs
109+
retention-days: 5
110+
path: |
111+
publish/*

.github/workflows/doc_publish.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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

.github/workflows/doc_remove.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Documentation Remove
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request_target:
8+
types: [closed]
9+
branches:
10+
- main
11+
12+
jobs:
13+
remove:
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- name: Try removal of PR-docs
17+
env:
18+
AZCOPY_CONCURRENCY_VALUE: 3000
19+
run: |
20+
azcopy rm "${{ vars.NCS_DOC_PR_STORAGE_URL }}addon-aliro/PR-${{ github.event.number }}?${{ secrets.NCS_DOC_SAS_PRS }}" --recursive=true || true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
manual.name=door_lock_and_access_control___VERSION__
2+
booktitle=nRF Door Lock and Access Control Add-on - __VERSION__

docs/_zoomin/aliro.tags.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Document tags for Zoomin.
2+
3+
# Tags for all topics:
4+
mapping_global:
5+
- aliro
6+
- door_lock_and_access_control___VERSION__
7+
- cluster_door_lock_and_access_control___VERSION__
8+
9+
# Tags for individual topics:
10+
mapping_topics: []

0 commit comments

Comments
 (0)