chore: upgrade docs CI

This commit is contained in:
Gabriel Dugny 2024-04-01 14:27:14 +02:00 committed by Emil Stenström
parent 163b0941c2
commit f56aa747c9

View file

@ -1,20 +1,67 @@
---
name: Test and Deploy Docs
on: on:
workflow_dispatch: push:
push: # XXX Commented-out for testing
# XXX Commented-out for testing # branches: [master]
# branches: workflow_dispatch:
# - main inputs:
ref:
description: "The commit SHA, tag, or branch to publish. Uses the default branch if not specified."
default: ""
type: string
release:
types: [published]
jobs: jobs:
deploy: docs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: # XXX Enable to avoid forks deploying
- uses: actions/checkout@v4 # if: github.ref == 'refs/heads/main' && github.repository_owner == 'EmilStenstrom'
with: steps:
fetch-depth: 0 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 with:
- run: pip install -r requirements-docs.txt fetch-depth: 0
- name: Publish Dev Docs - name: Set up Python
run: | uses: actions/setup-python@v5
git config user.name github-actions with:
git config user.email github-actions@github.com python-version: "3.12"
mike deploy --push dev
- name: Install Hatch
run: |
python -m pip install --upgrade pip wheel
python -m pip install -q hatch pre-commit
hatch --version
- name: Create Virtual Environment
run: hatch env create docs
- name: "Check for mkdocs build --strict"
run: |
hatch run docs:build --strict
# If pull request or not master branch and not a tag
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch'
- name: Configure git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Deploy docs (dev)
if: github.event_name == 'push' && github.ref_name == 'master' && github.ref_type == 'branch'
run: |
export SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
hatch run docs:mike deploy dev --update-aliases --title "dev (${SHORT_SHA})" --push
- name: Deploy docs (tag)
if: github.ref_type == 'tag' && github.event_name == 'push'
run: |
hatch run docs:mike deploy ${{ github.ref_name }} latest --push --update-aliases
hatch run docs:mike set-default latest --push
- name: Deploy docs (Released published)
if: github.event_name == 'release' && github.event.action == 'published' && github.ref_type == 'tag'
run: |
# Version from tag, keep leading v, from github.ref workflow variable
hatch run docs:mike deploy ${{ github.ref_name }} latest --push --update-aliases
hatch run docs:mike set-default latest --push