Skip to content

Update docs workflow and mkdocs config: add PlantUML support, edit/vi… #3

Update docs workflow and mkdocs config: add PlantUML support, edit/vi…

Update docs workflow and mkdocs config: add PlantUML support, edit/vi… #3

Workflow file for this run

name: Docs
on:
push:
branches: [develop]
paths:
- 'docs/**'
- 'mkdocs.yml'
- '.github/workflows/docs.yml'
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install mkdocs-material
run: pip install mkdocs-material plantuml-markdown
- name: Build and deploy to gh-pages (develop/)
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Fetch gh-pages if it exists
git fetch origin gh-pages:gh-pages 2>/dev/null || true
# Build the site
mkdocs build --strict --site-dir site
# Check out gh-pages (or create orphan)
if git rev-parse --verify gh-pages >/dev/null 2>&1; then
git checkout gh-pages
else
git checkout --orphan gh-pages
git rm -rf .
fi
# Clear develop/ subdirectory and copy new build
rm -rf develop/
cp -r site/ develop/
# Ensure v1 docs exist (copy from master if missing)
if [ ! -d "v1" ]; then
git checkout origin/master -- docs/ 2>/dev/null || true
if [ -d "docs" ]; then
mv docs v1
fi
fi
# Generate version index page
cat > index.html << 'INDEXEOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>phpGPX Documentation</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #fafafa;
color: #333;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.container { max-width: 600px; padding: 2rem; text-align: center; }
h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.tagline { color: #666; margin-bottom: 2.5rem; font-size: 1.1rem; }
.versions { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
.version-card {
display: block;
padding: 2rem 2.5rem;
border-radius: 12px;
text-decoration: none;
color: #333;
background: #fff;
border: 2px solid #e0e0e0;
transition: all 0.2s ease;
min-width: 200px;
}
.version-card:hover {
border-color: #009688;
box-shadow: 0 4px 12px rgba(0,150,136,0.15);
transform: translateY(-2px);
}
.version-card .ver { font-size: 1.5rem; font-weight: 700; }
.version-card .badge {
display: inline-block;
padding: 0.15rem 0.5rem;
border-radius: 4px;
font-size: 0.75rem;
font-weight: 600;
margin-left: 0.4rem;
vertical-align: middle;
}
.badge-stable { background: #e8f5e9; color: #2e7d32; }
.badge-dev { background: #fff3e0; color: #e65100; }
.version-card .desc { color: #888; font-size: 0.9rem; margin-top: 0.5rem; }
.github {
margin-top: 2.5rem;
color: #999;
font-size: 0.85rem;
}
.github a { color: #009688; text-decoration: none; }
.github a:hover { text-decoration: underline; }
</style>
</head>
<body>
<div class="container">
<h1>phpGPX</h1>
<p class="tagline">A PHP library for reading, creating, and manipulating GPX files</p>
<div class="versions">
<a href="v1/" class="version-card">
<div class="ver">1.x <span class="badge badge-stable">stable</span></div>
<div class="desc">Current release</div>
</a>
<a href="develop/" class="version-card">
<div class="ver">2.x <span class="badge badge-dev">develop</span></div>
<div class="desc">Next major version</div>
</a>
</div>
<p class="github">
<a href="https://github.com/Sibyx/phpGPX">GitHub</a> &middot;
<a href="https://packagist.org/packages/sibyx/phpgpx">Packagist</a>
</p>
</div>
</body>
</html>
INDEXEOF
# Commit and push
git add develop/ index.html
[ -d "v1" ] && git add v1/
git diff --cached --quiet || (git commit -m "Deploy docs from ${GITHUB_SHA::8}" && git push origin gh-pages)