Skip to content

Commit 1e812ff

Browse files
divipillaitrantanen
authored andcommitted
doc: Update the doc workflow for the new doc platform
Update the doc workflow for the new doc platform Signed-off-by: divya pillai <divya.pillai@nordicsemi.no>
1 parent 09be1a6 commit 1e812ff

6 files changed

Lines changed: 255 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: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Documentation Build and Publish
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-and-publish.yml'
27+
- '**.rst'
28+
- 'doc/**'
29+
push:
30+
branches:
31+
- main
32+
- 'v*-branch'
33+
tags:
34+
- v*
35+
36+
env:
37+
DOXYGEN_VERSION: 1.12.0
38+
39+
concurrency:
40+
group: ${{ github.workflow }}-${{ github.ref }}
41+
cancel-in-progress: true
42+
43+
jobs:
44+
doc-build-and-publish:
45+
env:
46+
ARCHIVE: "addon-serial_modem-${{inputs.documentation_tag}}.zip"
47+
48+
runs-on: ubuntu-latest
49+
50+
permissions:
51+
contents: write
52+
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Install dependencies
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install -y python3 python3-pip
61+
62+
- name: Install Python dependencies
63+
working-directory: doc
64+
run: |
65+
python3 -m pip install -r requirements.txt
66+
67+
- name: Install Doxygen
68+
run: |
69+
wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
70+
sudo tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
71+
echo "/opt/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH
72+
73+
- name: Build documentation
74+
working-directory: doc
75+
run: |
76+
doxygen
77+
sphinx-build -M html . build
78+
79+
cp custom.properties build/html
80+
sed -i 's/__VERSION__/'"${{inputs.documentation_tag}}"'/g' build/html/custom.properties
81+
82+
cp tags.yml build/html
83+
sed -i 's/__VERSION__/'"${{inputs.documentation_tag}}"'/g' build/html/tags.yml
84+
85+
cd build/html
86+
87+
zip -rq "${{env.ARCHIVE}}" .
88+
ls -lah .
89+
pwd
90+
91+
- name: Upload artifact
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: doc-build
95+
if-no-files-found: error
96+
retention-days: 2
97+
path: |
98+
doc/build/html/${{env.ARCHIVE}}
99+
100+
- name: Check version
101+
run: |
102+
VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$"
103+
if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then
104+
VERSION=${BASH_REMATCH[1]}
105+
elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then
106+
VERSION="latest"
107+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
108+
VERSION="pr-${{ github.event.number }}"
109+
fi
110+
echo "VERSION=${VERSION}"
111+
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
112+
113+
- name: Prepare Azure upload
114+
run: |
115+
116+
PUBLISH="$PWD/publish"
117+
mkdir -p "$PUBLISH"
118+
119+
MONITOR="monitor_${{ github.run_id }}.txt"
120+
121+
# Create documentation upload files
122+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
123+
ARCHIVE="legacy-addon-serial-modem-pr-${{ github.event.number }}.zip"
124+
echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}"
125+
echo "${{ github.event.number }}" > pr.txt
126+
else
127+
ARCHIVE="legacy-addon-serial-modem-${VERSION}.zip"
128+
echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}"
129+
fi
130+
131+
pushd "doc/build/html"
132+
zip -rq "${ARCHIVE}" .
133+
mv "${ARCHIVE}" "$PUBLISH"
134+
popd
135+
136+
mv "${MONITOR}" "$PUBLISH"
137+
if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi
138+
139+
- name: Store
140+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
141+
uses: actions/upload-artifact@v4
142+
with:
143+
name: docs
144+
retention-days: 5
145+
path: |
146+
publish/*

.github/workflows/doc-publish.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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-latest
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: doc
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: doc
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: doc
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 }}addons/serial-modem?$NCS_DOC_SAS_PRS" --recursive=true
51+
else
52+
azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addons/serial-modem?$NCS_DOC_SAS_MAIN" --recursive=true
53+
fi
54+
55+
- name: Find Comment
56+
if: ${{ github.event.workflow_run.event == 'pull_request' }}
57+
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3
58+
id: fc
59+
with:
60+
issue-number: ${{ env.PR }}
61+
comment-author: 'github-actions[bot]'
62+
body-includes: documentation preview
63+
64+
- name: Create or update comment
65+
if: ${{ github.event.workflow_run.event == 'pull_request' }}
66+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
67+
with:
68+
comment-id: ${{ steps.fc.outputs.comment-id }}
69+
issue-number: ${{ env.PR }}
70+
body: |
71+
You can find the documentation preview for this PR [here](${{ vars.NCS_DOC_PR_HOSTING_URL }}addons/serial-modem/PR-${{ env.PR }}/).
72+
edit-mode: replace
73+
74+
- name: Prepare Key
75+
run: |
76+
mkdir -p ~/.ssh
77+
ssh-keyscan upload-v1.zoominsoftware.io >> ~/.ssh/known_hosts
78+
79+
echo "${{ secrets.ZOOMIN_KEY }}" > zoomin_key
80+
chmod 600 zoomin_key
81+
82+
- name: Publish documentation - prod
83+
if: ${{inputs.publish_to_prod}}
84+
run: |
85+
sftp -v -i zoomin_key nordic@upload-v1.zoominsoftware.io <<EOF
86+
cd docs-be.nordicsemi.com/sphinx-html/incoming
87+
put doc/build/html/${{env.ARCHIVE}}
88+
EOF
89+
90+
- name: Publish documentation - dev
91+
if: ${{inputs.publish_to_dev}}
92+
run: |
93+
sftp -v -i zoomin_key nordic@upload-v1.zoominsoftware.io <<EOF
94+
cd nordic-be-dev.zoominsoftware.io/sphinx-html/incoming
95+
put doc/build/html/${{env.ARCHIVE}}
96+
EOF

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

doc/versions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
"2.0.99",
3+
"2.0.0-preview1",
4+
"1.0.1",
5+
"1.0.0",
6+
"0.3.0"
7+
]

0 commit comments

Comments
 (0)