Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 38 additions & 55 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,51 @@
name: Build Mkdocs Site
name: Build and Deploy MkDocs
on:
push:
branches:
- dev
- main

permissions:
contents: write

jobs:
docker:
name: Build Mkdocs site from docker container
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout dev branch
if: endsWith(github.ref, '/dev')
uses: actions/checkout@v2
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: dev
fetch-depth: 0
- name: Checkout main branch
if: endsWith(github.ref, '/main')
uses: actions/checkout@v2
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v5
with:
ref: main
fetch-depth: 0
- name: Setup git config
python-version: '3.10'
cache: 'pip'

- name: Install dependencies
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Build docker image
uses: docker/build-push-action@v2
python -m pip install --upgrade pip
pip install mkdocs mkdocs-material
pip install -r requirements.txt

- name: Build MkDocs
run: mkdocs build

- name: Deploy to Staging (from dev)
if: github.ref == 'refs/heads/dev'
uses: peaceiris/actions-gh-pages@v4
with:
context: .
push: false
tags: app:latest
- name: Run mkdocs build via docker
uses: addnab/docker-run-action@v3
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
publish_branch: site/staging
commit_message: "Deploy dev build to staging"

- name: Deploy to Production (from main)
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
image: app:latest
options: --rm -v ${{ github.workspace }}:/docs -v ${{ github.workspace }}/site:/site
run: |
git config --global --add safe.directory /docs;
mkdocs build;
- name: Commit dev updates to site/staging branch
if: endsWith(github.ref, '/dev')
run: |
sudo chown -R runner:docker site;
git stash -u;
git fetch;
git switch site/staging;
rm -rf site;
git clean -d -x -f;
git stash pop;
git add .;
git commit -m 'Gitbot actions site change';
git push origin;
- name: Commit main updates to site/production branch
if: endsWith(github.ref, '/main')
run: |
sudo chown -R runner:docker site;
git stash -u;
git fetch;
git switch site/production;
rm -rf site;
git clean -d -x -f;
git stash pop;
git add .;
git commit -m 'Gitbot actions site change';
git push origin;

github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
publish_branch: site/production
commit_message: "Deploy main build to production"