Skip to content

Commit 8b886be

Browse files
committed
doc: fix issue with monitor file
fix issue with monitor file Signed-off-by: divya pillai <divya.pillai@nordicsemi.no>
1 parent 1cc8e78 commit 8b886be

2 files changed

Lines changed: 123 additions & 78 deletions

File tree

.github/workflows/doc-build-and-publish.yml renamed to .github/workflows/doc-build.yml

Lines changed: 27 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ permissions:
44
contents: read
55

66
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
720
pull_request:
821
types: [opened, synchronize, reopened]
922
branches:
@@ -75,6 +88,15 @@ jobs:
7588
ls -lah .
7689
pwd
7790
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+
78100
- name: Check version
79101
run: |
80102
VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$"
@@ -120,84 +142,11 @@ jobs:
120142
mv "${MONITOR}" "$PUBLISH"
121143
if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi
122144
123-
- name: Unzip html archive
124-
working-directory: doc
125-
run: |
126-
OUTDIR=$(awk 'NR==1 { if ($3 ~ /^(latest|PR-[0-9]+|[0-9]+\.[0-9a-zA-Z\.\-]+)$/) print $3 }' monitor_*.txt)
127-
echo "OUTDIR=$OUTDIR" >> "$GITHUB_ENV"
128-
unzip legacy-addon-serial-modem*.zip -d $OUTDIR
129-
find "$OUTDIR" -type l -delete
130-
131-
- name: Obtain PR number
132-
if: ${{ github.event.workflow_run.event == 'pull_request' }}
133-
working-directory: doc
134-
run: |
135-
if [ -f pr.txt ]; then
136-
PR=$(head -n 1 pr.txt | tr -cd '0-9')
137-
fi
138-
printf 'PR=%s\n' "$PR" >> "$GITHUB_ENV"
139-
140-
- name: Upload to Azure storage
141-
working-directory: doc
142-
env:
143-
AZCOPY_CONCURRENCY_VALUE: 1024
144-
NCS_DOC_SAS_PRS: ${{ secrets.NCS_DOC_SAS_PRS }}
145-
NCS_DOC_SAS_MAIN: ${{ secrets.NCS_DOC_SAS_MAIN }}
146-
run: |
147-
if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then
148-
azcopy cp $OUTDIR "${{ vars.NCS_DOC_PR_STORAGE_URL }}addons/serial-modem?$NCS_DOC_SAS_PRS" --recursive=true
149-
else
150-
azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addons/serial-modem?$NCS_DOC_SAS_MAIN" --recursive=true
151-
fi
152-
153-
- name: Upload artifact
145+
- name: Store
146+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
154147
uses: actions/upload-artifact@v4
155148
with:
156-
name: doc-build
157-
if-no-files-found: error
158-
retention-days: 2
149+
name: docs
150+
retention-days: 5
159151
path: |
160-
doc/build/html/${{env.ARCHIVE}}
161-
162-
- name: Prepare Key
163-
run: |
164-
mkdir -p ~/.ssh
165-
ssh-keyscan upload-v1.zoominsoftware.io >> ~/.ssh/known_hosts
166-
167-
echo "${{ secrets.ZOOMIN_KEY }}" > zoomin_key
168-
chmod 600 zoomin_key
169-
170-
- name: Publish documentation - prod
171-
if: ${{inputs.publish_to_prod}}
172-
run: |
173-
sftp -v -i zoomin_key nordic@upload-v1.zoominsoftware.io <<EOF
174-
cd docs-be.nordicsemi.com/sphinx-html/incoming
175-
put doc/build/html/${{env.ARCHIVE}}
176-
EOF
177-
178-
- name: Publish documentation - dev
179-
if: ${{inputs.publish_to_dev}}
180-
run: |
181-
sftp -v -i zoomin_key nordic@upload-v1.zoominsoftware.io <<EOF
182-
cd nordic-be-dev.zoominsoftware.io/sphinx-html/incoming
183-
put doc/build/html/${{env.ARCHIVE}}
184-
EOF
185-
186-
- name: Find Comment
187-
if: ${{ github.event.workflow_run.event == 'pull_request' }}
188-
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3
189-
id: fc
190-
with:
191-
issue-number: ${{ env.PR }}
192-
comment-author: 'github-actions[bot]'
193-
body-includes: documentation preview
194-
195-
- name: Create or update comment
196-
if: ${{ github.event.workflow_run.event == 'pull_request' }}
197-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
198-
with:
199-
comment-id: ${{ steps.fc.outputs.comment-id }}
200-
issue-number: ${{ env.PR }}
201-
body: |
202-
You can find the documentation preview for this PR [here](${{ vars.NCS_DOC_PR_HOSTING_URL }}addons/serial-modem/PR-${{ env.PR }}/).
203-
edit-mode: replace
152+
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

0 commit comments

Comments
 (0)