-
-
Notifications
You must be signed in to change notification settings - Fork 40
96 lines (84 loc) · 4.65 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
# From https://github.com/Ext-Creators/discord-ext-ipc/blob/main/.github/workflows/deploy.yml
# Copyright 2020-present Ext-Creators
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Deploy
on:
push:
release:
types: [released]
jobs:
job:
name: Build docs
runs-on: ubuntu-latest
env:
AUTH_EMAIL: [email protected]
AUTH_LOGIN: Gobot1234
AUTH_TOKEN: ${{ secrets.DOCS_TOKEN }}
COMMIT_MESSAGE: update docs for ${{ github.repository }}
PULL_INSTALL: .[docs]
PULL_PATH: docs
PUSH_REPOSITORY: steam-py/steam-py.github.io
PUSH_ROOT_PATH: docs
PUSH_LATEST_PATH: latest
PUSH_STABLE_PATH: stable
PYTHON_VERSION: 3.9
SPHINX_OPTIONS: -b dirhtml -a -E -n -T -W --keep-going
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.event.repository.name }}
- name: Checkout ${{ env.PUSH_REPOSITORY }}
uses: actions/checkout@v2
with:
path: docs
repository: ${{ env.PUSH_REPOSITORY }}
token: ${{ env.AUTH_TOKEN }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install
working-directory: ./${{ github.event.repository.name }}
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade ${{ env.PULL_INSTALL }}
- name: Build
if: ${{ github.event_name == 'push' }}
run: |
if [ -d ./docs/${{ env.PUSH_ROOT_PATH }}/${{ env.PUSH_LATEST_PATH }} ]; then rm -r ./docs/${{ env.PUSH_ROOT_PATH }}/${{ env.PUSH_LATEST_PATH }}; fi
python -m sphinx ${{ env.SPHINX_OPTIONS }} ./${{ github.event.repository.name }}/${{ env.PULL_PATH }} ./docs/${{ env.PUSH_ROOT_PATH }}/${{ env.PUSH_LATEST_PATH }}
x=${{ env.PUSH_ROOT_PATH }}/${{ env.PUSH_LATEST_PATH }}; y=$x; while [ $y != ${y%/*} ]; do y=${y%/*}; echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0;url='"${x#$y/}"'" /></head><body></body></html>' > ./docs/$y/index.html; done
if [ ! -f ./docs/index.json ]; then echo {} > ./docs/index.json ; fi
jq 'if has("'"${{ env.PUSH_ROOT_PATH }}"'") then (.'"${{ env.PUSH_ROOT_PATH }}"'.latest = "${{ env.PUSH_LATEST_PATH }}" | .'"${{ env.PUSH_ROOT_PATH }}"'.stable = "${{ env.PUSH_STABLE_PATH }}") else (.'"${{ env.PUSH_ROOT_PATH }}"' = {latest: "${{ env.PUSH_LATEST_PATH }}", stable: "${{ env.PUSH_STABLE_PATH }}", tags: []}) end' ./docs/index.json > ./docs/temp.json
mv ./docs/temp.json ./docs/index.json
- name: Build
if: ${{ github.event_name == 'release' }}
run: |
if [ -d ./docs/${{ env.PUSH_ROOT_PATH }}/${{ github.event.release.tag_name }} ]; then rm -r ./docs/${{ env.PUSH_ROOT_PATH }}/${{ github.event.release.tag_name }}; fi
python -m sphinx ${{ env.SPHINX_OPTIONS }} ./${{ github.event.repository.name }}/${{ env.PULL_PATH }} ./docs/${{ env.PUSH_ROOT_PATH }}/${{ github.event.release.tag_name }}
if [ -h ./docs/${{ env.PUSH_ROOT_PATH }}/${{ env.PUSH_STABLE_PATH }} ]; then rm ./docs/${{ env.PUSH_ROOT_PATH }}/${{ env.PUSH_STABLE_PATH }}; fi
ln -s ${{ github.event.release.tag_name }} ./docs/${{ env.PUSH_ROOT_PATH }}/${{ env.PUSH_STABLE_PATH }}
if [ ! -f ./docs/index.json ]; then echo {} > ./docs/index.json ; fi
jq 'if has("'"${{ env.PUSH_ROOT_PATH }}"'") then (.'"${{ env.PUSH_ROOT_PATH }}"'.latest = "${{ env.PUSH_LATEST_PATH }}" | .'"${{ env.PUSH_ROOT_PATH }}"'.stable = "${{ env.PUSH_STABLE_PATH }}" | .'"${{ env.PUSH_ROOT_PATH }}"'.tags |= . + ["${{ github.event.release.tag_name }}"]) else (.'"${{ env.PUSH_ROOT_PATH }}"' = {latest: "${{ env.PUSH_LATEST_PATH }}", stable: "${{ env.PUSH_STABLE_PATH }}", tags: ["${{ github.event.release.tag_name }}"]}) end' ./docs/index.json > ./docs/temp.json
mv ./docs/temp.json ./docs/index.json
- name: Push
continue-on-error: true
working-directory: docs
run: |
git config user.name ${{ env.AUTH_LOGIN }}
git config user.email ${{ env.AUTH_EMAIL }}
git add .
git commit -m "${{ env.COMMIT_MESSAGE }}"
git push