mirror of
https://github.com/marceloprates/prettymaps.git
synced 2026-02-01 11:33:22 +01:00
59 lines
1.9 KiB
YAML
59 lines
1.9 KiB
YAML
# Deploy Docs to GitHub Pages using MkDocs
|
|
# This workflow builds documentation from the 'docs/' folder using mkdocs.yml in the repo root
|
|
# and deploys the static site to GitHub Pages.
|
|
|
|
name: Build Docs and Push Site
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-push-site:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
# Ensure mkdocs.yml exists in the repo root
|
|
- name: Check for mkdocs.yml in root
|
|
run: |
|
|
if [ ! -f mkdocs.yml ]; then
|
|
echo "Error: mkdocs.yml not found in repository root. Please add it." && exit 1
|
|
fi
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install -r docs/requirements.txt
|
|
- name: Build docs with MkDocs
|
|
run: |
|
|
mkdocs build
|
|
- name: List files after build
|
|
run: |
|
|
pwd
|
|
ls -l
|
|
ls -l site || true
|
|
- name: Push site/ to site-artifact branch
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git checkout --orphan site-artifact
|
|
# Remove everything except .git
|
|
find . -mindepth 1 ! -regex '^./.git\(/.*\)?' -delete
|
|
# Check if site/ exists and is not empty
|
|
if [ ! -d site ] || [ -z "$(ls -A site)" ]; then
|
|
echo "site/ directory does not exist or is empty. MkDocs build may have failed."
|
|
exit 1
|
|
fi
|
|
# Copy site output to root (including hidden files)
|
|
cp -a site/. .
|
|
touch .nojekyll
|
|
git add .
|
|
if git diff --cached --quiet; then
|
|
echo 'No changes to commit'
|
|
else
|
|
git commit -m "Update built site from main"
|
|
git push --force origin site-artifact
|
|
fi |