MkDocs Publish Docs on GitHub Pages CI #1
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: "MkDocs Publish Docs on GitHub Pages CI" | |
on: | |
# Manually trigger workflow | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: Build MkDocs from Branch (Optional) | |
required: false | |
# Trigger when a push happens | |
# to select branches. | |
push: | |
branches: | |
- master | |
env: | |
PYTHON_VERSION: "3.8" | |
USER_SPECIFIED_BRANCH: ${{ github.event.inputs.branch }} | |
REPO_OWNER: ${{ github.repository_owner }} # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python runtime | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install Python dependencies for MkDocs | |
run: | | |
echo "REPO_OWNER: ${{ env.REPO_OWNER }}" | |
ls | |
pip install -r requirements/docs.txt | |
- name: Install all other dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Deploy documentation | |
env: | |
FONTAWESOME_KIT: ${{ secrets.FONTAWESOME_KIT }} | |
run: | | |
# Check if user-provided branch exists | |
# then switch to that branch. | |
if [[ -z $(git branch --list "${{ env.USER_SPECIFIED_BRANCH }}") ]]; \ | |
then (\ | |
echo "Switching to branch: ${{ env.USER_SPECIFIED_BRANCH }}" && \ | |
git checkout ${{ env.USER_SPECIFIED_BRANCH }} \ | |
); else USER_SPECIFIED_BRANCH=${GITHUB_REF##*/} ; fi && \ | |
echo "Current Git Branch: ${USER_SPECIFIED_BRANCH}" | |
# Install chalk from current branch | |
python -m pip install "." | |
# Begin Deploying MkDocs | |
mkdocs gh-deploy --force | |
mkdocs --version |