Add mkdocs mike for versions #103
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy docs | |
on: # yamllint disable-line rule:truthy | |
pull_request: | |
branches: | |
- main | |
push: | |
tags: | |
- v* | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
pip install mkdocs mkdocs-material mike \ | |
mkdocs-awesome-pages-plugin beautifulsoup4 lxml | |
- name: Copy all to docs folder | |
run: | | |
mkdir -p docs | |
shopt -s extglob | |
mv !(docs) docs/ | |
- name: Deploy documentation | |
run: | | |
if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
VERSION=${{ github.ref_name }} | |
fi | |
export BASE_URL=${BASE_URL}/${VERSION:-main} | |
VERSION=$(echo $VERSION | awk -F'.' '{print $1"."$2}') | |
git fetch origin ${DOCS_BRANCH} --depth=1 | |
mike deploy -F ${DOCS_CONFIG} \ | |
--push --branch ${DOCS_BRANCH} \ | |
--update-aliases ${VERSION:-main} latest | |
mike set-default -F ${DOCS_CONFIG} \ | |
--push --branch ${DOCS_BRANCH} latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GIT_COMMITTER_NAME: ci-bot | |
GIT_COMMITTER_EMAIL: [email protected] | |
BASE_URL: https://github.com/SciCatProject/scicatlive/blob | |
DOCS_BRANCH: gh-pages | |
DOCS_CONFIG: .github/mkdocs.yaml |