forked from platformio/platformio-core
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (104 loc) · 3.05 KB
/
docs.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: docs
on:
schedule:
- cron: '30 9 * * *'
push:
branches:
- main
paths:
- '**/docs.yml'
env:
DOCS_FOR: pio
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
token: ${{ secrets.OSQ_REPO_TOKEN }}
fetch-depth: 1
- name: Checkout Docs
uses: actions/checkout@v3
with:
repository: OS-Q/docs
token: ${{ secrets.OSQ_REPO_TOKEN }}
ref: ${{ env.DOCS_FOR }}
fetch-depth: 1
path: www
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
working-directory: www
run: |
python -m pip install --upgrade pip
pip install tox
- name: Build docs
working-directory: www
run: |
tox -e docs
- name: Preserve Docs
run: |
tar -czvf docs.tar.gz -C www/_build html rtdpage
tree -L 2
- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: docs
path: docs.tar.gz
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
env:
DOCS_REPO: OS-Q/web
DOCS_DIR: docs
LATEST_DOCS_DIR: latest
RELEASE_BUILD: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: docs
- name: Unpack artifact
run: |
mkdir ./${{ env.LATEST_DOCS_DIR }}
tar -xzf ./docs.tar.gz -C ./${{ env.LATEST_DOCS_DIR }}
- name: Delete Artifact
uses: geekyeggo/delete-artifact@v2
with:
name: docs
- name: Checkout latest Docs
continue-on-error: true
uses: actions/checkout@v4
with:
repository: ${{ env.DOCS_REPO }}
path: ${{ env.DOCS_DIR }}
ref: gh-pages
- name: Synchronize Docs
run: |
rm -rf ${{ env.DOCS_DIR }}/.git
rm -rf ${{ env.DOCS_DIR }}/${{ env.DOCS_FOR }}/
mkdir -p ${{ env.DOCS_DIR }}/${{ env.DOCS_FOR }}/
cp -rf ${{ env.LATEST_DOCS_DIR }}/html/* ${{ env.DOCS_DIR }}/${{ env.DOCS_FOR }}/
if [[ ${{ env.RELEASE_BUILD }} == false ]]; then
rm -rf ${{ env.DOCS_DIR }}/${{ env.DOCS_FOR }}/page
mkdir -p ${{ env.DOCS_DIR }}/${{ env.DOCS_FOR }}/page
cp -rf ${{ env.LATEST_DOCS_DIR }}/rtdpage/* ${{ env.DOCS_DIR }}/${{ env.DOCS_FOR }}/page
fi
- name: Validate Docs
run: |
if [ -z "$(ls -A ${{ env.DOCS_DIR }})" ]; then
echo "Docs folder is empty. Aborting!"
exit 1
fi
- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.OSQ_REPO_TOKEN }}
external_repository: ${{ env.DOCS_REPO }}
publish_dir: ./${{ env.DOCS_DIR }}
commit_message: Sync Docs