Skip to content

add messages to assertion checks (#133) #55

add messages to assertion checks (#133)

add messages to assertion checks (#133) #55

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
echo "MKDOCS_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
else
echo "MIKE_ALIAS=dev" >> $GITHUB_ENV
echo "MKDOCS_VERSION=$(hatch version | grep -Po '.+dev')" >> $GITHUB_ENV
fi
echo "${MKDOCS_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:cff-snippets
hatch run docs:mike deploy --update-aliases --push ${MKDOCS_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 ${MKDOCS_VERSION} ]; then mkdir ${MKDOCS_VERSION}; fi
echo '{"schemaVersion":1,"label":"Docs","message":"${{ env.BADGE_MSG }}","color":"${{ env.BADGE_COLOUR }}","namedLogo":"materialformkdocs","logoColor":"white"}' | tee ./${MKDOCS_VERSION}/badge-mkdocs.json
git add ./${MKDOCS_VERSION}/badge-mkdocs.json
git commit -m "github-actions update badge ${MKDOCS_VERSION}"
git push origin gh-pages