-
-
Notifications
You must be signed in to change notification settings - Fork 75
96 lines (83 loc) · 2.98 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
name: Publish docs
on:
release:
types:
- published
jobs:
check:
name: Prepare
runs-on: ubuntu-latest
outputs:
status: ${{ steps.check.outputs.status }}
version: ${{ steps.check.outputs.version }}
tag: ${{ steps.check.outputs.tag }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Find version
id: get_version
uses: battila7/get-version-action@v2
- name: Version format check
id: check
run: |
if [ "${{ steps.get_version.outputs.is-semver }}" == "true" ]
then
echo "::set-output name=status::ok"
echo "::set-output name=version::${{ steps.get_version.outputs.major }}.${{ steps.get_version.outputs.minor }}"
echo "::set-output name=tag::${{ steps.get_version.outputs.version-without-v }}"
fi
build:
name: Deploy docs
runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.status == 'ok'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: pip install -r docs/requirements.txt
- name: Set up git author
uses: oleksiyrudenko/gha-git-credentials@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Find latest release
id: latest
uses: pozetroninc/[email protected]
with:
repository: ${{ github.repository }}
excludes: draft
- name: Deploy docs
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
run: |
# Setup SSH deploy key
mkdir -p ~/.ssh
echo "${SSH_DEPLOY_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H github.com > ~/.ssh/known_hosts
- run: git remote add doc [email protected]:CuyZ/Valinor-Documentation.git
- run: git fetch doc gh-pages --verbose
- run: |
# Check if the "latest" alias exists
VALINOR_HAS_LATEST=$(mike list --config-file docs/mkdocs.yml --remote doc | grep latest) || true
# If so then it is set as the default version (to enable the index redirect)
if [ "${VALINOR_HAS_LATEST}" != "" ]
then
echo "Set latest as default"
mike set-default latest --config-file docs/mkdocs.yml --remote doc
fi
- run: |
if [ "${{ steps.latest.outputs.release }}" = "${{ needs.check.outputs.tag }}" ]
then
# Here we deploy a new latest version
mike deploy ${{ needs.check.outputs.version }} latest --config-file docs/mkdocs.yml --update-aliases --push --remote doc
else
# Here we deploy a version that's not the latest one
mike deploy ${{ needs.check.outputs.version }} --config-file docs/mkdocs.yml --push --remote doc
fi