1- name : Docs Site
1+ name : update documentation site
22
33on :
44 push :
55 branches :
66 - main
7- pull_request :
8- release :
9- types : [released]
7+ tags :
8+ - v*
9+
10+ permissions :
11+ contents : write
12+
1013jobs :
11- build :
14+ deplou :
1215 runs-on : ubuntu-latest
13- permissions :
14- contents : write
1516 steps :
16- - name : Checkout source
17- uses : actions/checkout@v3
17+ - uses : actions/checkout@v4
1818 with :
19- fetch-depth : 0
20-
21- - name : Setup Docs Deploy
19+ fetch-depth : 0 # fetch all commits/branches
20+ - uses : actions/setup-python@v5
21+ with :
22+ python-version : 3.x
23+ - uses : actions/cache@v4
24+ with :
25+ key : ${{ github.ref }}
26+ path : .cache
27+ - name : Install Python dependencies
2228 run : |
23- git config --global user.name "GitHub Actions"
24- git config --global user.email "[email protected] " 25-
26- - name : Get the latest tag
29+ cd doc-site
30+ pip install -r requirements.txt
31+ - name : Configure git user
2732 run : |
28- git fetch --tags
29- latest_tag=$(git tag -l | sort -V | grep -v "rc" | tail -n 1)
30- echo "latest tag: $latest_tag"
31- echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
32-
33- - name : Install docs dependencies
34- working-directory : doc-site
35- run : pip install -r requirements.txt
36-
37- - name : Update doc site for release
38- if : github.event.action == 'released' && github.ref_name != env.LATEST_TAG
39- working-directory : doc-site
40- run : mike deploy ${{ github.event.release.tag_name }} --push
41-
42- - name : Update doc site for latest release
43- if : github.event.action == 'released' && github.ref_name == env.LATEST_TAG
44- working-directory : doc-site
45- run : mike deploy ${{ github.event.release.tag_name }} latest -u --push
46-
47- - name : Update doc site for `main` branch
48- if : ${{ github.event_name == 'push' }}
49- working-directory : doc-site
50- run : mike deploy head --push
51-
52- - name : Test building the doc site but do not deploy it
53- if : ${{ github.event_name == 'pull_request' }}
54- working-directory : doc-site
55- run : mkdocs build
33+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
34+ git config --local user.name "github-actions[bot]"
35+ - name : Deploy docs
36+ run : |
37+ cd doc-site
38+ # Strip git ref prefix from version
39+ echo "${{ github.ref }}"
40+ VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
41+ # Strip "v" prefix from tag name
42+ [[ "${{ github.ref }}" == "refs/tags/"* ]] && ALIAS=$(echo $VERSION | sed -e 's/^v//')
43+ # If building from main, use latest as ALIAS
44+ [ "$VERSION" == "main" ] && ALIAS=latest
45+ echo $VERSION $ALIAS
46+ mike deploy --push --update-aliases $VERSION $ALIAS
47+ mike set-default latest
0 commit comments