Skip to content

Commit 1dd92ec

Browse files
committed
ci: doc: Publish pull request docs to builds.zephyrproject.io
This commit updates the CI documentation build workflow to upload the HTML pull request documentation builds to the S3 builds.zephyrproject.io bucket so that they are directly accessible from the web. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 88d64ad commit 1dd92ec

File tree

3 files changed

+86
-8
lines changed

3 files changed

+86
-8
lines changed

.github/workflows/doc-build.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ name: Documentation Build
55

66
on:
77
schedule:
8-
- cron: '0 */3 * * *'
8+
- cron: '0 */3 * * *'
99
push:
1010
tags:
11-
- v*
11+
- v*
1212
pull_request:
1313
paths:
1414
- 'doc/**'
@@ -96,6 +96,23 @@ jobs:
9696
name: html-output
9797
path: html-output.tar.xz
9898

99+
- name: process-pr
100+
if: github.event_name == 'pull_request'
101+
run: |
102+
REPO_NAME="${{ github.event.repository.name }}"
103+
PR_NUM="${{ github.event.pull_request.number }}"
104+
DOC_URL="https://builds.zephyrproject.io/${REPO_NAME}/pr/${PR_NUM}/docs/"
105+
106+
echo "${PR_NUM}" > pr_num
107+
echo "::notice:: Documentation will be available shortly at: ${DOC_URL}"
108+
109+
- name: upload-pr-number
110+
uses: actions/upload-artifact@v2
111+
if: github.event_name == 'pull_request'
112+
with:
113+
name: pr_num
114+
path: pr_num
115+
99116
doc-build-pdf:
100117
name: "Documentation Build (PDF)"
101118
runs-on: ubuntu-latest
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright (c) 2020 Linaro Limited.
2+
# Copyright (c) 2021 Nordic Semiconductor ASA
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Documentation Publish (Pull Request)
6+
7+
on:
8+
workflow_run:
9+
workflows: ["Documentation Build"]
10+
types:
11+
- completed
12+
13+
jobs:
14+
doc-publish:
15+
name: Publish Documentation
16+
runs-on: ubuntu-latest
17+
if: |
18+
github.event.workflow_run.event == 'pull_request' &&
19+
github.event.workflow_run.conclusion == 'success' &&
20+
github.repository == 'zephyrproject-rtos/zephyr'
21+
22+
steps:
23+
- name: Download artifacts
24+
uses: dawidd6/action-download-artifact@v2
25+
with:
26+
workflow: doc-build.yml
27+
run_id: ${{ github.event.workflow_run.id }}
28+
29+
- name: Load PR number
30+
run: |
31+
echo "PR_NUM=$(<pr_num/pr_num)" >> $GITHUB_ENV
32+
33+
- name: Check PR number
34+
id: check-pr
35+
uses: carpentries/actions/[email protected]
36+
with:
37+
pr: ${{ env.PR_NUM }}
38+
sha: ${{ github.event.workflow_run.head_sha }}
39+
40+
- name: Validate PR number
41+
if: steps.check-pr.outputs.VALID != 'true'
42+
run: |
43+
echo "ABORT: PR number validation failed!"
44+
exit 1
45+
46+
- name: Uncompress HTML docs
47+
run: |
48+
tar xf html-output/html-output.tar.xz -C html-output
49+
50+
- name: Configure AWS Credentials
51+
uses: aws-actions/configure-aws-credentials@v1
52+
with:
53+
aws-access-key-id: ${{ secrets.AWS_BUILDS_ZEPHYR_PR_ACCESS_KEY_ID }}
54+
aws-secret-access-key: ${{ secrets.AWS_BUILDS_ZEPHYR_PR_SECRET_ACCESS_KEY }}
55+
aws-region: us-east-1
56+
57+
- name: Upload to AWS S3
58+
env:
59+
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
60+
run: |
61+
aws s3 sync --quiet html-output/html \
62+
s3://builds.zephyrproject.org/${{ github.event.repository.name }}/pr/${PR_NUM}/docs \
63+
--delete

.github/workflows/doc-publish.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
# Copyright (c) 2021 Nordic Semiconductor ASA
33
# SPDX-License-Identifier: Apache-2.0
44

5-
name: Publish Documentation
5+
name: Documentation Publish
66

77
on:
88
workflow_run:
99
workflows: ["Documentation Build"]
1010
branches:
11-
- main
12-
- v*
13-
tags:
14-
- v*
11+
- main
12+
- v*
1513
types:
16-
- completed
14+
- completed
1715

1816
jobs:
1917
doc-publish:

0 commit comments

Comments
 (0)