Skip to content

Commit 9e3efd9

Browse files
committed
doc: Add doc workflow for new doc platform
Add doc workflow for new doc platform. Signed-off-by: divya pillai <divya.pillai@nordicsemi.no>
1 parent e086957 commit 9e3efd9

7 files changed

Lines changed: 272 additions & 117 deletions

File tree

.github/workflows/doc-build-and-publish-zoomin.yml

Lines changed: 0 additions & 116 deletions
This file was deleted.

.github/workflows/doc-build.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Documentation Build
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
documentation_tag:
10+
type: string
11+
required: false
12+
default: "latest"
13+
description: "Label of the documentation"
14+
publish_to_prod:
15+
type: boolean
16+
default: true
17+
publish_to_dev:
18+
type: boolean
19+
default: true
20+
pull_request:
21+
types: [opened, synchronize, reopened]
22+
branches:
23+
- main
24+
- 'v*-branch'
25+
paths:
26+
- '.github/workflows/doc-build.yml'
27+
- '.github/workflows/doc-publish.yml'
28+
- '**.rst'
29+
- 'doc/**'
30+
- "include/**"
31+
push:
32+
branches:
33+
- main
34+
- 'v*-branch'
35+
tags:
36+
- v*
37+
38+
env:
39+
DOXYGEN_VERSION: 1.12.0
40+
41+
concurrency:
42+
group: ${{ github.workflow }}-${{ github.ref }}
43+
cancel-in-progress: true
44+
45+
jobs:
46+
build:
47+
runs-on: ubuntu-24.04
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
51+
with:
52+
ref: ${{ github.event.pull_request.head.sha }}
53+
54+
- name: Install system dependencies
55+
run: |
56+
wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
57+
sudo tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
58+
echo "/opt/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
62+
with:
63+
python-version: 3.12
64+
cache: pip
65+
cache-dependency-path: doc/requirements.txt
66+
pip-install: |
67+
-r doc/requirements.txt
68+
69+
- name: Build
70+
run: |
71+
doxygen
72+
sphinx-build -M html . build
73+
74+
- name: Check version
75+
run: |
76+
VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$"
77+
if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then
78+
VERSION=${BASH_REMATCH[1]}
79+
elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then
80+
VERSION="latest"
81+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
82+
VERSION="pr-${{ github.event.number }}"
83+
fi
84+
echo "VERSION=${VERSION}"
85+
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
86+
87+
- name: Prepare Azure upload
88+
run: |
89+
PUBLISH="$PWD/publish"
90+
mkdir -p "$PUBLISH"
91+
92+
MONITOR="monitor_${{ github.run_id }}.txt"
93+
94+
# Create documentation upload files
95+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
96+
ARCHIVE="legacy-addon-serial_modem-pr-${{ github.event.number }}.zip"
97+
echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}"
98+
echo "${{ github.event.number }}" > pr.txt
99+
else
100+
ARCHIVE="legacy-addon-serial_modem-${VERSION}.zip"
101+
echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}"
102+
fi
103+
104+
pushd "doc/build/html"
105+
zip -rq "${ARCHIVE}" .
106+
mv "${ARCHIVE}" "$PUBLISH"
107+
popd
108+
109+
mv "${MONITOR}" "$PUBLISH"
110+
if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi
111+
112+
- name: Prepare Zoomin upload
113+
if: ${{ github.event_name == 'push' }}
114+
working-directory: doc
115+
run: |
116+
PUBLISH="$PWD/publish"
117+
mkdir -p "$PUBLISH"
118+
119+
OUTDIR=doc/build/html
120+
ARCHIVE="addon-serial_modem_$VERSION.zip"
121+
122+
cp doc/custom.properties "$OUTDIR/custom.properties"
123+
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties"
124+
125+
cp doc/tags.yml "$OUTDIR/tags.yml"
126+
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml"
127+
128+
pushd "$OUTDIR"
129+
zip -rq "$ARCHIVE" .
130+
mv "$ARCHIVE" "$PUBLISH"
131+
popd
132+
133+
- name: Store
134+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
135+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
136+
with:
137+
name: docs
138+
retention-days: 5
139+
path: |
140+
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-serial_modem*.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 Zoomin documentation
43+
if: >
44+
github.event.workflow_run.head_branch == 'main' &&
45+
github.event.workflow_run.head_repository.full_name == github.repository
46+
env:
47+
NCS_ZOOMIN_KEY: ${{ secrets.NCS_ZOOMIN_KEY }}
48+
run: |
49+
# trust server
50+
mkdir -p ~/.ssh
51+
ssh-keyscan ${{ vars.NCS_ZOOMIN_SERVER }} >> ~/.ssh/known_hosts
52+
53+
# prepare key
54+
touch zoomin_key
55+
chmod 600 zoomin_key
56+
echo "$NCS_ZOOMIN_KEY" | base64 -d > zoomin_key
57+
58+
# upload files
59+
for file in docs/addon-serial_modem*.zip; do
60+
sftp -v -i zoomin_key ${{ vars.NCS_ZOOMIN_USER }}@${{ vars.NCS_ZOOMIN_SERVER }} <<EOF
61+
cd docs-be.nordicsemi.com/sphinx-html/incoming
62+
put ${file}
63+
cd ../../../nordic-be-dev.zoominsoftware.io/sphinx-html/incoming
64+
put ${file}
65+
quit
66+
EOF
67+
done
68+
69+
- name: Upload to Azure storage
70+
working-directory: docs
71+
env:
72+
AZCOPY_CONCURRENCY_VALUE: 1024
73+
NCS_DOC_SAS_PRS: ${{ secrets.NCS_DOC_SAS_PRS }}
74+
NCS_DOC_SAS_MAIN: ${{ secrets.NCS_DOC_SAS_MAIN }}
75+
run: |
76+
if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then
77+
azcopy cp $OUTDIR "${{ vars.NCS_DOC_PR_STORAGE_URL }}addon-serial_modem?$NCS_DOC_SAS_PRS" --recursive=true
78+
else
79+
azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addon-serial_modem?$NCS_DOC_SAS_MAIN" --recursive=true
80+
fi
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-serial_modem/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-serial_modem/PR-${{ github.event.number }}?${{ secrets.NCS_DOC_SAS_PRS }}" --recursive=true || true

doc/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3737

3838
html_theme = 'sphinx_ncs_theme'
39+
html_theme_options = {
40+
'docsets': {},
41+
}
42+
43+
html_extra_path = ['versions.json']
3944

4045
## -- Options for Breathe ----------------------------------------------------
4146
# https://breathe.readthedocs.io/en/latest/index.html

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Sphinx==5.3.0
22
breathe==4.35.0
3-
sphinx-ncs-theme==0.7.4
3+
sphinx-ncs-theme<1.1
44
sphinx-tabs>=3.4
55
sphinx-togglebutton>=0.3.2
66
Pillow>=9.0.1

0 commit comments

Comments
 (0)