Skip to content

Build and Publish using MkDocs #31

Build and Publish using MkDocs

Build and Publish using MkDocs #31

Workflow file for this run

name: Build and Publish using MkDocs
on:
push:
# Applies only to tags not pushed by GH Actions (see: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token)
tags:
- '2.*'
workflow_dispatch:
# For easily adding a new tag and deploying
inputs:
version:
description: 'New tag to add and deploy'
required: true
jobs:
check-version:
runs-on: ubuntu-latest
name: Check version is valid
if: github.ref == 'refs/heads/v2docs'
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- name: Set version (user committed tag)
if: ${{ github.event_name == 'push' }}
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Set version (actions workflow)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Set version output
id: version
run: echo "value=$VERSION" >> $GITHUB_OUTPUT
- name: Verify version regex is for a 2.x.x release
run: echo $VERSION | grep -E '^(2)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
add-version:
runs-on: ubuntu-latest
name: Add version tag
if: ${{ github.event_name == 'workflow_dispatch' }}
needs: check-version
env:
VERSION: ${{ needs.check-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Configure git
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Add release tag
# Force is used to replace any existing tag for the same version
run: git tag -f $VERSION
- name: Push tag
run: git push -f origin $VERSION
build-deploy:
runs-on: ubuntu-latest
name: Build & Deploy
needs: [check-version, add-version]
env:
VERSION: ${{ needs.check-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Configure git
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Build and deploy MkDocs using mike
run: mike deploy --push --no-redirect --update-aliases $VERSION latest