Skip to content

Commit c320a92

Browse files
authored
Add docs deploy 2 for testing (#25416)
1 parent c475ec2 commit c320a92

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/docs_deploy2.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Docs - Deploy PX4 User Guide to AWS
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'release/**'
8+
paths:
9+
- 'docs/en/**'
10+
pull_request:
11+
branches:
12+
- '**'
13+
paths:
14+
- 'docs/en/**'
15+
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
id-token: write # for AWS OIDC
21+
22+
concurrency:
23+
group: docs-deploy
24+
cancel-in-progress: false
25+
26+
env:
27+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
28+
29+
jobs:
30+
build:
31+
runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
32+
steps:
33+
- uses: runs-on/action@v1
34+
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Node
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: 20
42+
cache: npm
43+
cache-dependency-path: ./docs/yarn.lock
44+
45+
- name: Install dependencies
46+
run: yarn install --frozen-lockfile --cwd ./docs
47+
48+
- name: Build with VitePress
49+
working-directory: ./docs
50+
run: |
51+
npm run docs:build_ubuntu
52+
touch .vitepress/dist/.nojekyll
53+
npm run docs:sitemap
54+
55+
- name: Upload artifact
56+
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged) || github.event_name == 'workflow_dispatch' }}
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: px4_docs_build
60+
path: docs/.vitepress/dist/
61+
retention-days: 1
62+
63+
deploy:
64+
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged) || github.event_name == 'workflow_dispatch' }}
65+
needs: build
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Download Artifact
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: px4_docs_build
73+
path: ~/_book
74+
75+
- name: Configure AWS from OIDC
76+
uses: aws-actions/configure-aws-credentials@v4
77+
with:
78+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
79+
aws-region: us-west-2
80+
81+
- name: Sanity check AWS credentials
82+
run: aws sts get-caller-identity
83+
84+
- name: Upload HTML with short cache
85+
run: |
86+
aws s3 sync ~/_book/ s3://px4-docs/${{ env.BRANCH_NAME }}/ \
87+
--delete \
88+
--exclude "*" --include "*.html" \
89+
--cache-control "public, max-age=60"
90+
91+
- name: Upload assets with long cache
92+
run: |
93+
aws s3 sync ~/_book/ s3://px4-docs/${{ env.BRANCH_NAME }}/ \
94+
--delete \
95+
--exclude "*.html" \
96+
--cache-control "public, max-age=86400, immutable"
97+

0 commit comments

Comments
 (0)