-
Notifications
You must be signed in to change notification settings - Fork 26
88 lines (77 loc) · 2.78 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
name: docs
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install CPython dependencies
run: |
python -m pip install --upgrade pip
python -m pip install compas@git+https://github.com/compas-dev/compas@main # TODO: remove once new `Part` is released.
python -m pip install --no-cache-dir -r requirements-dev.txt
- name: 📃 Generate docs
id: docs
shell: bash
run: |
invoke docs --check-links
# Get branch/tag/latest name from git
GITHUB_REF_REGEX="tags/v([0-9a-zA-Z\.\-]+)|(pull/[0-9]+)|heads/(.+)"
if [[ $GITHUB_REF =~ $GITHUB_REF_REGEX ]]; then
if [[ $BASH_REMATCH = pull* ]]; then
BRANCH_OR_TAG=pull_${BASH_REMATCH##*/}
echo "commit_type=pull" >> $GITHUB_OUTPUT
elif [[ $BASH_REMATCH = tags/v* ]]; then
# 2nd element is tag, #v replaces prefix v
BRANCH_OR_TAG=${BASH_REMATCH[1]#v}
echo "commit_type=tag" >> $GITHUB_OUTPUT
else
BRANCH_OR_TAG=${BASH_REMATCH##*/}
fi;
if [[ $BRANCH_OR_TAG = main ]]; then
BRANCH_OR_TAG=latest
echo "commit_type=main" >> $GITHUB_OUTPUT
fi;
fi;
echo "Docs will be deployed to https://gramaziokohler.github.io/compas_timber/$BRANCH_OR_TAG"
mkdir -p deploy/$BRANCH_OR_TAG && mv -T dist/docs deploy/$BRANCH_OR_TAG/
# Check index.html and .nojekyll
- shell: bash -l {0}
run: |
echo check index.html and .nojekyll
cd deploy
if [[ ! -f ".nojekyll" ]]; then
echo creating .nojekyll
> .nojekyll
fi
full_repo=${{ github.repository }}
repo=${full_repo#*/}
if [[ ! -f "index.html" ]]; then
echo creating index.html
echo '<meta http-equiv="refresh" content="0; url=/'$repo'/latest/">' > index.html
fi
if [[ ${{ steps.docs.outputs.commit_type }} == "tag" ]]; then
echo update index.html to point at ${{ steps.docs.outputs.current_version }}
echo '<meta http-equiv="refresh" content="0; url=/'$repo'/${{ steps.docs.outputs.current_version }}/">' > index.html
fi
- name: 🚢 Deploy docs
if: success()
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: deploy
keep_history: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}