mirror of
https://github.com/marceloprates/prettymaps.git
synced 2025-08-20 05:11:43 +02:00
Simplify documentation deployment by using GitHub Pages action.
This commit is contained in:
31
.github/workflows/docs.yml
vendored
31
.github/workflows/docs.yml
vendored
@@ -2,7 +2,7 @@
|
|||||||
# This workflow builds documentation from the 'docs/' folder using mkdocs.yml in the repo root
|
# This workflow builds documentation from the 'docs/' folder using mkdocs.yml in the repo root
|
||||||
# and deploys the static site to GitHub Pages.
|
# and deploys the static site to GitHub Pages.
|
||||||
|
|
||||||
name: Build Docs and Push Site
|
name: Build and Deploy Docs
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -10,7 +10,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push-site:
|
build-and-deploy-docs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -35,25 +35,8 @@ jobs:
|
|||||||
pwd
|
pwd
|
||||||
ls -l
|
ls -l
|
||||||
ls -l site || true
|
ls -l site || true
|
||||||
- name: Push site/ to site-artifact branch
|
- name: Deploy to GitHub Pages
|
||||||
run: |
|
uses: peaceiris/actions-gh-pages@v4
|
||||||
git config --global user.name "github-actions[bot]"
|
with:
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
git checkout --orphan site-artifact
|
publish_dir: ./site
|
||||||
# Remove everything except .git
|
|
||||||
find . -mindepth 1 ! -regex '^./.git\(/.*\)?' -delete
|
|
||||||
# Check if site/ exists and contains at least one file
|
|
||||||
if [ ! -d site ] || [ "$(find site -type f | wc -l)" -eq 0 ]; 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
|
|
Reference in New Issue
Block a user