Skip to content

Commit 6c4fa15

Browse files
authored
doc: fix publishing workflow1 (#4)
fix publishing workflow1 Signed-off-by: divya pillai <divya.pillai@nordicsemi.no>
1 parent 1b56f0e commit 6c4fa15

2 files changed

Lines changed: 11 additions & 56 deletions

File tree

.github/workflows/doc-build.yml

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ concurrency:
4444

4545
jobs:
4646
doc-build-and-publish:
47+
env:
48+
ARCHIVE: "addon-serial_modem-${{inputs.documentation_tag}}.zip"
49+
4750
runs-on: ubuntu-latest
4851

4952
permissions:
@@ -69,49 +72,21 @@ jobs:
6972
sudo tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
7073
echo "/opt/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH
7174
72-
- name: Compute documentation tag
73-
id: doc_meta
74-
run: |
75-
# Manual dispatch honors `documentation_tag`; otherwise derive from ref / event.
76-
DOCUMENTATION_TAG='${{ inputs.documentation_tag || '' }}'
77-
78-
VERSION_REGEX='^v([0-9a-zA-Z\.\-]+)$'
79-
if [[ -z "$DOCUMENTATION_TAG" ]] && [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then
80-
DOCUMENTATION_TAG="${BASH_REMATCH[1]}"
81-
fi
82-
83-
if [[ -z "$DOCUMENTATION_TAG" ]] && [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then
84-
DOCUMENTATION_TAG="latest"
85-
fi
86-
87-
if [[ -z "$DOCUMENTATION_TAG" ]] && [[ "${{ github.event_name }}" == "pull_request" ]]; then
88-
DOCUMENTATION_TAG="PR-${{ github.event.pull_request.number }}"
89-
fi
90-
91-
if [[ -z "$DOCUMENTATION_TAG" ]]; then
92-
DOCUMENTATION_TAG="latest"
93-
fi
94-
95-
echo "documentation_tag=${DOCUMENTATION_TAG}" >> "$GITHUB_OUTPUT"
96-
echo "DOCUMENTATION_TAG=${DOCUMENTATION_TAG}" >> "$GITHUB_ENV"
97-
ARCHIVE_NAME="addon-serial_modem-${DOCUMENTATION_TAG}.zip"
98-
echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> "$GITHUB_ENV"
99-
10075
- name: Build documentation
10176
working-directory: doc
10277
run: |
10378
doxygen
10479
sphinx-build -M html . build
10580
10681
cp custom.properties build/html
107-
sed -i 's/__VERSION__/'"${DOCUMENTATION_TAG}"'/g' build/html/custom.properties
82+
sed -i 's/__VERSION__/'"${{inputs.documentation_tag}}"'/g' build/html/custom.properties
10883
10984
cp tags.yml build/html
110-
sed -i 's/__VERSION__/'"${DOCUMENTATION_TAG}"'/g' build/html/tags.yml
85+
sed -i 's/__VERSION__/'"${{inputs.documentation_tag}}"'/g' build/html/tags.yml
11186
11287
cd build/html
11388
114-
zip -rq "${ARCHIVE_NAME}" .
89+
zip -rq "${{env.ARCHIVE}}" .
11590
ls -lah .
11691
pwd
11792
@@ -122,18 +97,17 @@ jobs:
12297
if-no-files-found: error
12398
retention-days: 2
12499
path: |
125-
doc/build/html/${{ env.ARCHIVE_NAME }}
100+
doc/build/html/${{env.ARCHIVE}}
126101
127102
- name: Check version
128103
run: |
129-
# Align with `monitor_*.txt` field 3 and doc-publish `OUTDIR` awk pattern.
130104
VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$"
131105
if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then
132106
VERSION=${BASH_REMATCH[1]}
133107
elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then
134108
VERSION="latest"
135109
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
136-
VERSION="PR-${{ github.event.number }}"
110+
VERSION="pr-${{ github.event.number }}"
137111
fi
138112
echo "VERSION=${VERSION}"
139113
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"

.github/workflows/doc-publish.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ jobs:
1616
runs-on: ubuntu-latest
1717
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1818
steps:
19-
# `working-directory: doc/` requires that directory to exist. Without checkout,
20-
# artifacts download to the repo root; `path: doc` places `docs` contents under `./doc`.
2119
- name: Download artifacts
2220
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6
2321
with:
@@ -44,34 +42,17 @@ jobs:
4442
printf 'PR=%s\n' "$PR" >> "$GITHUB_ENV"
4543
4644
- name: Upload to Azure storage
45+
working-directory: doc
4746
env:
4847
AZCOPY_CONCURRENCY_VALUE: 1024
4948
NCS_DOC_SAS_PRS: ${{ secrets.NCS_DOC_SAS_PRS }}
5049
NCS_DOC_SAS_MAIN: ${{ secrets.NCS_DOC_SAS_MAIN }}
5150
run: |
52-
set -euo pipefail
53-
SRC="${GITHUB_WORKSPACE}/doc/${OUTDIR}"
54-
if [[ ! -d "$SRC" ]]; then
55-
echo "::error::Upload source missing: ${SRC}"
56-
ls -la "${GITHUB_WORKSPACE}/doc" || true
57-
exit 1
58-
fi
5951
if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then
60-
BASE="${{ vars.NCS_DOC_PR_STORAGE_URL }}"
61-
SAS="${NCS_DOC_SAS_PRS:-}"
52+
azcopy cp $OUTDIR "${{ vars.NCS_DOC_PR_STORAGE_URL }}addons/serial-modem?$NCS_DOC_SAS_PRS" --recursive=true
6253
else
63-
BASE="${{ vars.NCS_DOC_STORAGE_URL }}"
64-
SAS="${NCS_DOC_SAS_MAIN:-}"
65-
fi
66-
# AzCopy treats non-https targets as local paths. Empty BASE yields "addons/serial-modem?..." and Local/Local errors.
67-
if [[ -z "$BASE" ]] || [[ "$BASE" != http://* && "$BASE" != https://* ]]; then
68-
echo "::error::Blob base URL missing or invalid. Set vars.NCS_DOC_STORAGE_URL (push) or vars.NCS_DOC_PR_STORAGE_URL (PR) to e.g. https://<account>.blob.core.windows.net/<container>/"
69-
exit 1
54+
azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addons/serial-modem?$NCS_DOC_SAS_MAIN" --recursive=true
7055
fi
71-
BASE="${BASE%/}/"
72-
DEST="${BASE}addons/serial-modem?${SAS}"
73-
echo "Uploading to blob prefix ${BASE}addons/serial-modem"
74-
azcopy copy "$SRC" "$DEST" --recursive --from-to LocalBlob
7556
7657
- name: Find Comment
7758
if: ${{ github.event.workflow_run.event == 'pull_request' }}

0 commit comments

Comments
 (0)