mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
* Tone down the performance of some runners from 8cpu+ down to 4cpu+ * Improve and document caching on PX4 builds with an improved ccache key strategy * Review and document artifact upload logic for binaries uploaded to S3 and github releases * Future Improvement, introduce runners configuration file so we can control more precesily which instances are allocated. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
117 lines
3.3 KiB
YAML
117 lines
3.3 KiB
YAML
name: Docs - Deploy PX4 User Guide to AWS
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
- "release/**"
|
|
paths:
|
|
- "docs/en/**"
|
|
- "docs/zh/**"
|
|
- "docs/uk/**"
|
|
- "docs/ko/**"
|
|
pull_request:
|
|
paths:
|
|
- "docs/en/**"
|
|
- "docs/zh/**"
|
|
- "docs/uk/**"
|
|
- "docs/ko/**"
|
|
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: read
|
|
id-token: write # for AWS OIDC
|
|
|
|
concurrency:
|
|
group: docs-deploy
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
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
|
|
|
|
- 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
|
|
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged) || github.event_name == 'workflow_dispatch' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: px4_docs_build
|
|
path: docs/.vitepress/dist/
|
|
retention-days: 1
|
|
|
|
deploy:
|
|
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged) || github.event_name == 'workflow_dispatch' }}
|
|
needs: build
|
|
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.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.outputs.releaseversion }}/ \
|
|
--delete \
|
|
--exclude "*.html" \
|
|
--cache-control "public, max-age=86400, immutable"
|