2022-03-26 18:19:50 +08:00
|
|
|
# Copyright (c) 2020 Linaro Limited.
|
|
|
|
# Copyright (c) 2021 Nordic Semiconductor ASA
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
name: Documentation Publish (Pull Request)
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows: ["Documentation Build"]
|
|
|
|
types:
|
|
|
|
- completed
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
doc-publish:
|
|
|
|
name: Publish Documentation
|
2022-11-18 20:07:01 +08:00
|
|
|
runs-on: ubuntu-22.04
|
2022-03-26 18:19:50 +08:00
|
|
|
if: |
|
|
|
|
github.event.workflow_run.event == 'pull_request' &&
|
|
|
|
github.event.workflow_run.conclusion == 'success' &&
|
|
|
|
github.repository == 'zephyrproject-rtos/zephyr'
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download artifacts
|
2024-10-15 21:55:57 +08:00
|
|
|
id: download-artifacts
|
2024-08-26 13:30:01 +08:00
|
|
|
uses: dawidd6/action-download-artifact@v6
|
2022-03-26 18:19:50 +08:00
|
|
|
with:
|
|
|
|
workflow: doc-build.yml
|
|
|
|
run_id: ${{ github.event.workflow_run.id }}
|
2024-10-15 21:55:57 +08:00
|
|
|
if_no_artifact_found: ignore
|
2022-03-26 18:19:50 +08:00
|
|
|
|
|
|
|
- name: Load PR number
|
2024-10-15 21:55:57 +08:00
|
|
|
if: steps.download-artifacts.outputs.found_artifact == 'true'
|
2024-10-29 19:20:26 +08:00
|
|
|
uses: actions/github-script@v7
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
let fs = require("fs");
|
|
|
|
let pr_number = Number(fs.readFileSync("./pr_num/pr_num"));
|
|
|
|
core.exportVariable("PR_NUM", pr_number);
|
2022-03-26 18:19:50 +08:00
|
|
|
|
|
|
|
- name: Check PR number
|
2024-10-15 21:55:57 +08:00
|
|
|
if: steps.download-artifacts.outputs.found_artifact == 'true'
|
2022-03-26 18:19:50 +08:00
|
|
|
id: check-pr
|
2023-04-15 14:37:12 +08:00
|
|
|
uses: carpentries/actions/check-valid-pr@v0.14.0
|
2022-03-26 18:19:50 +08:00
|
|
|
with:
|
|
|
|
pr: ${{ env.PR_NUM }}
|
|
|
|
sha: ${{ github.event.workflow_run.head_sha }}
|
|
|
|
|
|
|
|
- name: Validate PR number
|
2024-10-15 21:55:57 +08:00
|
|
|
if: |
|
|
|
|
steps.download-artifacts.outputs.found_artifact == 'true' &&
|
|
|
|
steps.check-pr.outputs.VALID != 'true'
|
2022-03-26 18:19:50 +08:00
|
|
|
run: |
|
|
|
|
echo "ABORT: PR number validation failed!"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
- name: Uncompress HTML docs
|
2024-10-15 21:55:57 +08:00
|
|
|
if: steps.download-artifacts.outputs.found_artifact == 'true'
|
2022-03-26 18:19:50 +08:00
|
|
|
run: |
|
|
|
|
tar xf html-output/html-output.tar.xz -C html-output
|
2024-03-02 09:59:01 +08:00
|
|
|
if [ -f api-coverage/api-coverage.tar.xz ]; then
|
|
|
|
tar xf api-coverage/api-coverage.tar.xz -C api-coverage
|
|
|
|
fi
|
2022-03-26 18:19:50 +08:00
|
|
|
|
|
|
|
- name: Configure AWS Credentials
|
2024-10-15 21:55:57 +08:00
|
|
|
if: steps.download-artifacts.outputs.found_artifact == 'true'
|
2024-04-23 01:09:42 +08:00
|
|
|
uses: aws-actions/configure-aws-credentials@v4
|
2022-03-26 18:19:50 +08:00
|
|
|
with:
|
2023-05-12 01:06:29 +08:00
|
|
|
aws-access-key-id: ${{ vars.AWS_BUILDS_ZEPHYR_PR_ACCESS_KEY_ID }}
|
2022-03-26 18:19:50 +08:00
|
|
|
aws-secret-access-key: ${{ secrets.AWS_BUILDS_ZEPHYR_PR_SECRET_ACCESS_KEY }}
|
|
|
|
aws-region: us-east-1
|
|
|
|
|
|
|
|
- name: Upload to AWS S3
|
2024-10-15 21:55:57 +08:00
|
|
|
if: steps.download-artifacts.outputs.found_artifact == 'true'
|
2022-03-26 18:19:50 +08:00
|
|
|
env:
|
|
|
|
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
|
|
|
|
run: |
|
|
|
|
aws s3 sync --quiet html-output/html \
|
|
|
|
s3://builds.zephyrproject.org/${{ github.event.repository.name }}/pr/${PR_NUM}/docs \
|
|
|
|
--delete
|
2024-03-02 09:59:01 +08:00
|
|
|
if [ -d api-coverage/coverage-report ]; then
|
|
|
|
aws s3 sync --quiet api-coverage/coverage-report/ \
|
|
|
|
s3://builds.zephyrproject.org/${{ github.event.repository.name }}/pr/${PR_NUM}/api-coverage \
|
|
|
|
--delete
|
|
|
|
fi
|