-
Notifications
You must be signed in to change notification settings - Fork 1.7k
96 lines (83 loc) · 2.85 KB
/
docs_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Deploy Docs
on:
push:
branches:
- 'main'
- 'v*'
tags:
- 'v*'
#paths:
# - docs/**
pull_request:
branches:
- '*'
#paths:
# - docs/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
#with:
#fetch-depth: 0 # Not needed if lastUpdated is not enabled
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn # or pnpm / yarn
- name: Install dependencies
run: yarn install
- name: Build with VitePress
run: |
yarn docs:build_ubuntu
touch .vitepress/dist/.nojekyll
yarn docs:sitemap
#touch docs/.vitepress/dist/.nojekyll
- 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: .vitepress/dist # 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: Deploy
run: |
git clone --single-branch --branch main https://${{ secrets.PX4BUILTBOT_PERSONAL_ACCESS_TOKEN }}@github.com/PX4/docs.px4.io.git
rm -rf docs.px4.io/${BRANCH_NAME}
mkdir -p docs.px4.io/${BRANCH_NAME}
cp -r ~/_book/* docs.px4.io/${BRANCH_NAME}/
cd docs.px4.io
git config --global user.name "${{ secrets.PX4BUILDBOT_USER }}"
git config --global user.email "${{ secrets.PX4BUILDBOT_EMAIL }}"
git add ${BRANCH_NAME}
git commit -a -m "PX4 docs build update (vitepress) `date`"
#git add .
#git commit --amend -m "PX4 docs build update (vitepress) `date`"
#git commit --allow-empty -m "Empty commit to force rebuild"
git push origin main -f