-
Notifications
You must be signed in to change notification settings - Fork 34
63 lines (53 loc) · 2.05 KB
/
mkdocs-publish.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
name: Publish docs via GitHub Pages
on: [push, pull_request]
jobs:
mkdocs:
name: build mkdocs
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update clone config
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin gh-pages --depth=1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
# required to use caching because it depends on requirements.txt
- name: Setup Hatch
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- name: Set ENV Vars
run: |
if [ "${GITHUB_REF_NAME}" == "main" ]; then
echo "MIKE_ALIAS=latest" >> $GITHUB_ENV
else
echo "MIKE_ALIAS=dev" >> $GITHUB_ENV
fi
echo "HATCH_VERSION=$(hatch version)" >> $GITHUB_ENV
echo "${HATCH_VERSION} ${MIKE_ALIAS}"
echo "BADGE_MSG=fail" >> $GITHUB_ENV
echo "BADGE_COLOUR=red" >> $GITHUB_ENV
- name: Build docs examples
id: build
run: |
hatch run docs:build-examples
hatch run docs:cli-snippets
hatch run docs:mike deploy --update-aliases --push ${HATCH_VERSION} ${MIKE_ALIAS}
echo "BADGE_MSG=pass" >> $GITHUB_ENV
echo "BADGE_COLOUR=green" >> $GITHUB_ENV
- name: Write Badges
if: always()
run: |
git checkout gh-pages
if [ ! -d ${HATCH_VERSION} ]; then mkdir ${HATCH_VERSION}; fi
echo '{"schemaVersion":1,"label":"Docs","message":"${{ env.BADGE_MSG }}","color":"${{ env.BADGE_COLOUR }}","namedLogo":"materialformkdocs","logoColor":"white"}' | tee ./${HATCH_VERSION}/badge-mkdocs.json
git add ./${HATCH_VERSION}/badge-mkdocs.json
git commit -m "github-actions update badge ${HATCH_VERSION}"
git push origin gh-pages