Skip to content

Commit

Permalink
Add mkdocs mike for versions
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Jul 17, 2024
1 parent 1dd502a commit 8de2406
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ site_name: SciCatLive
docs_dir: ../docs
theme:
name: material
custom_dir: overrides

extra:
version:
provider: mike

plugins:
- search
- awesome-pages:
collapse_single_pages: true
- mike

markdown_extensions:
- admonition
Expand Down
15 changes: 15 additions & 0 deletions .github/overrides/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "base.html" %}

<!-- prevent caching -->
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

{% block outdated %}
You're not viewing the latest released version.
<a href="{{ '../' ~ base_url }}">
<strong>Click here to go to latest release.</strong>
</a>
{% endblock %}
29 changes: 25 additions & 4 deletions .github/workflows/mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: # yamllint disable-line rule:truthy
push:
branches:
- main
tags:
- v*

jobs:
build:
Expand All @@ -19,15 +21,34 @@ jobs:

- name: Install dependencies
run: |
pip install mkdocs mkdocs-material \
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: Build and Deploy
run: mkdocs gh-deploy --force --config-file .github/mkdocs.yaml
- name: Deploy documentation
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG=${{ github.ref_name }}
VERSION=$(echo ${TAG} | awk -F'.' '{print $1"."$2}')
fi
export BASE_URL=${BASE_URL}/${TAG:-main}
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:
BASE_URL: https://github.com/SciCatProject/scicatlive/blob/main
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

0 comments on commit 8de2406

Please sign in to comment.