mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
The sticky-pull-request-comment action requires a non-empty file when using the path input. When the filtered link checker finds no broken links in changed files, it produces an empty file causing the action to fail with "Either message or path input is required". Ensure the results file always has content by writing a fallback message when the file is missing or empty. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
398 lines
12 KiB
YAML
398 lines
12 KiB
YAML
name: Docs - Orchestrator
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
- "release/**"
|
|
paths:
|
|
- "docs/**"
|
|
- "src/**"
|
|
- "msg/**"
|
|
- "ROMFS/**"
|
|
- "Tools/module_config/**"
|
|
pull_request:
|
|
paths:
|
|
- "docs/**"
|
|
- ".github/workflows/docs-orchestrator.yml"
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: docs-orchestrator-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# =============================================================================
|
|
# Detect Changes (PR only)
|
|
# =============================================================================
|
|
detect-changes:
|
|
name: "T1: Detect Changes"
|
|
if: github.event_name == 'pull_request'
|
|
permissions:
|
|
contents: read
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
source_changed: ${{ steps.changes.outputs.source }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dorny/paths-filter@v3
|
|
id: changes
|
|
with:
|
|
filters: |
|
|
source:
|
|
- 'src/**'
|
|
- 'msg/**'
|
|
- 'ROMFS/**'
|
|
- 'Tools/module_config/**'
|
|
|
|
# =============================================================================
|
|
# PR Metadata Regen (conditional - only when PR touches source files)
|
|
# =============================================================================
|
|
pr-metadata-regen:
|
|
name: "T2: PR Metadata"
|
|
needs: [detect-changes]
|
|
if: github.event_name == 'pull_request' && needs.detect-changes.outputs.source_changed == 'true'
|
|
permissions:
|
|
contents: read
|
|
runs-on: [runs-on,runner=4cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
|
|
container:
|
|
image: px4io/px4-dev-nuttx-focal:2024-11-07
|
|
steps:
|
|
- uses: runs-on/action@v1
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Cache Restore - ccache
|
|
id: cache-ccache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ~/.ccache
|
|
key: ccache-docs-metadata-${{ github.sha }}
|
|
restore-keys: |
|
|
ccache-docs-metadata-
|
|
|
|
- name: Setup ccache
|
|
run: |
|
|
mkdir -p ~/.ccache
|
|
echo "max_size = 1G" > ~/.ccache/ccache.conf
|
|
|
|
- name: Build px4_sitl_default
|
|
run: |
|
|
make px4_sitl_default
|
|
env:
|
|
CCACHE_DIR: ~/.ccache
|
|
|
|
- name: Install Emscripten
|
|
run: |
|
|
git clone https://github.com/emscripten-core/emsdk.git /opt/emsdk
|
|
cd /opt/emsdk
|
|
./emsdk install 3.1.64
|
|
./emsdk activate 3.1.64
|
|
|
|
- name: Build failsafe_web
|
|
run: |
|
|
source /opt/emsdk/emsdk_env.sh
|
|
make failsafe_web
|
|
|
|
- name: Sync all metadata
|
|
run: Tools/ci/metadata_sync.sh --sync all
|
|
|
|
- name: Upload metadata artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: pr-metadata
|
|
path: docs/
|
|
retention-days: 1
|
|
|
|
# =============================================================================
|
|
# Push Metadata Regen (main/release branches)
|
|
# =============================================================================
|
|
metadata-regen:
|
|
name: "T2: Metadata Sync"
|
|
if: github.event_name == 'push'
|
|
permissions:
|
|
contents: write
|
|
runs-on: [runs-on,runner=4cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
|
|
container:
|
|
image: px4io/px4-dev-nuttx-focal:2024-11-07
|
|
steps:
|
|
- uses: runs-on/action@v1
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
token: ${{ secrets.PX4BUILTBOT_PERSONAL_ACCESS_TOKEN }}
|
|
|
|
- name: Cache Restore - ccache
|
|
id: cache-ccache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ~/.ccache
|
|
key: ccache-docs-metadata-${{ github.sha }}
|
|
restore-keys: |
|
|
ccache-docs-metadata-
|
|
|
|
- name: Setup ccache
|
|
run: |
|
|
mkdir -p ~/.ccache
|
|
echo "max_size = 1G" > ~/.ccache/ccache.conf
|
|
|
|
- name: Build px4_sitl_default
|
|
run: |
|
|
make px4_sitl_default
|
|
env:
|
|
CCACHE_DIR: ~/.ccache
|
|
|
|
- name: Cache Save - ccache
|
|
uses: actions/cache/save@v4
|
|
if: always()
|
|
with:
|
|
path: ~/.ccache
|
|
key: ccache-docs-metadata-${{ github.sha }}
|
|
|
|
- name: Install Emscripten
|
|
run: |
|
|
git clone https://github.com/emscripten-core/emsdk.git /opt/emsdk
|
|
cd /opt/emsdk
|
|
./emsdk install 3.1.64
|
|
./emsdk activate 3.1.64
|
|
|
|
- name: Build failsafe_web
|
|
run: |
|
|
source /opt/emsdk/emsdk_env.sh
|
|
make failsafe_web
|
|
|
|
- name: Sync all metadata
|
|
run: Tools/ci/metadata_sync.sh --sync all
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: ./docs/yarn.lock
|
|
|
|
- name: Format markdown with Prettier
|
|
run: |
|
|
cd docs
|
|
yarn install --frozen-lockfile
|
|
yarn prettier --write "en/**/*.md"
|
|
|
|
- name: Commit and push changes
|
|
run: |
|
|
git config --global user.name "${{ secrets.PX4BUILDBOT_USER }}"
|
|
git config --global user.email "${{ secrets.PX4BUILDBOT_EMAIL }}"
|
|
git add docs/
|
|
if git diff --staged --quiet; then
|
|
echo "No changes to commit"
|
|
else
|
|
git commit -m "docs: auto-sync metadata [skip ci]
|
|
|
|
Co-Authored-By: PX4 BuildBot <${{ secrets.PX4BUILDBOT_EMAIL }}>"
|
|
git push
|
|
fi
|
|
|
|
# =============================================================================
|
|
# Link Check
|
|
# =============================================================================
|
|
link-check:
|
|
name: "T2: Link Check"
|
|
needs: [detect-changes, pr-metadata-regen]
|
|
if: always() && (github.event_name == 'pull_request')
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 0
|
|
|
|
- name: Download metadata artifact
|
|
if: needs.pr-metadata-regen.result == 'success'
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: pr-metadata
|
|
path: docs/
|
|
|
|
- name: Get changed doc files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@v46.0.5
|
|
with:
|
|
json: true
|
|
write_output_files: true
|
|
output_dir: ./logs
|
|
base_sha: ${{ github.event.pull_request.base.sha }}
|
|
sha: ${{ github.event.pull_request.head.sha }}
|
|
files: |
|
|
docs/en/**/*.md
|
|
|
|
- name: Save changed files list
|
|
run: |
|
|
mv ./logs/all_changed_files.json ./logs/prFiles.json
|
|
echo "Changed files:"
|
|
cat ./logs/prFiles.json
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Run filtered link checker (changed files)
|
|
run: |
|
|
npm -g install markdown_link_checker_sc@0.0.138
|
|
if [ "$(jq length ./logs/prFiles.json)" -gt 0 ]; then
|
|
markdown_link_checker_sc \
|
|
-r "$GITHUB_WORKSPACE" \
|
|
-d docs \
|
|
-e en \
|
|
-f ./logs/prFiles.json \
|
|
-i assets \
|
|
-u docs.px4.io/main/ \
|
|
> ./logs/filtered-link-check-results.md || true
|
|
fi
|
|
if [ ! -s ./logs/filtered-link-check-results.md ]; then
|
|
echo "No broken links found in changed files." > ./logs/filtered-link-check-results.md
|
|
fi
|
|
cat ./logs/filtered-link-check-results.md
|
|
|
|
- name: Run full link checker
|
|
run: |
|
|
markdown_link_checker_sc \
|
|
-r "$GITHUB_WORKSPACE" \
|
|
-d docs \
|
|
-e en \
|
|
-i assets \
|
|
-u docs.px4.io/main/ \
|
|
> ./logs/link-check-results.md || true
|
|
cat ./logs/link-check-results.md
|
|
|
|
- name: Post PR comment with link check results
|
|
uses: marocchino/sticky-pull-request-comment@v2
|
|
with:
|
|
header: flaws
|
|
path: ./logs/filtered-link-check-results.md
|
|
|
|
- name: Upload link check results
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: link-check-results
|
|
path: logs/
|
|
retention-days: 7
|
|
|
|
# =============================================================================
|
|
# Build Site
|
|
# =============================================================================
|
|
build-site:
|
|
name: "T3: Build Site"
|
|
needs: [detect-changes, pr-metadata-regen, metadata-regen, link-check]
|
|
if: >-
|
|
always() &&
|
|
(needs.metadata-regen.result == 'success' || needs.metadata-regen.result == 'skipped') &&
|
|
(needs.link-check.result == 'success' || needs.link-check.result == 'skipped')
|
|
permissions:
|
|
contents: read
|
|
runs-on: [runs-on,runner=4cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
|
|
outputs:
|
|
branchname: ${{ steps.set-branch.outputs.branchname }}
|
|
releaseversion: ${{ steps.set-version.outputs.releaseversion }}
|
|
steps:
|
|
- uses: runs-on/action@v1
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
|
|
|
- name: Download metadata artifact (PR)
|
|
if: github.event_name == 'pull_request' && needs.pr-metadata-regen.result == 'success'
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: pr-metadata
|
|
path: docs/
|
|
|
|
- id: set-branch
|
|
run: echo "branchname=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
|
|
|
|
- id: set-version
|
|
run: |
|
|
branch="${{ steps.set-branch.outputs.branchname }}"
|
|
if [[ "$branch" == "main" ]]; then
|
|
version="main"
|
|
else
|
|
version="v${branch#release/}"
|
|
fi
|
|
echo "releaseversion=$version" >> $GITHUB_OUTPUT
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: ./docs/yarn.lock
|
|
|
|
- name: Install dependencies
|
|
run: yarn install --frozen-lockfile --cwd ./docs
|
|
|
|
- name: Build with VitePress
|
|
working-directory: ./docs
|
|
env:
|
|
BRANCH_NAME: ${{ steps.set-version.outputs.releaseversion }}
|
|
run: |
|
|
npm run docs:build_ubuntu
|
|
touch .vitepress/dist/.nojekyll
|
|
npm run docs:sitemap
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: px4_docs_build
|
|
path: docs/.vitepress/dist/
|
|
retention-days: 1
|
|
|
|
# =============================================================================
|
|
# Deploy to AWS (push only)
|
|
# =============================================================================
|
|
deploy-aws:
|
|
name: "T4: Deploy"
|
|
if: github.event_name == 'push'
|
|
needs: [metadata-regen, build-site]
|
|
permissions:
|
|
id-token: write
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: px4_docs_build
|
|
path: ~/_book
|
|
|
|
- name: Configure AWS from OIDC
|
|
uses: aws-actions/configure-aws-credentials@v4
|
|
with:
|
|
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
|
aws-region: us-west-2
|
|
|
|
- name: Sanity check AWS credentials
|
|
run: aws sts get-caller-identity
|
|
|
|
- name: Upload HTML with short cache
|
|
run: |
|
|
aws s3 sync ~/_book/ s3://px4-docs/${{ needs.build-site.outputs.releaseversion }}/ \
|
|
--delete \
|
|
--exclude "*" --include "*.html" \
|
|
--cache-control "public, max-age=60"
|
|
|
|
- name: Upload assets with long cache
|
|
run: |
|
|
aws s3 sync ~/_book/ s3://px4-docs/${{ needs.build-site.outputs.releaseversion }}/ \
|
|
--delete \
|
|
--exclude "*.html" \
|
|
--cache-control "public, max-age=86400, immutable"
|