This commit is contained in:
@@ -1,61 +1,43 @@
|
|||||||
name: Build Notes Site
|
name: Build and Push Static files
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main # Trigger on pushes to your default branch
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: node:20-bookworm # Node for checkout
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 1️⃣ Checkout repository
|
- name: Checkout Code
|
||||||
- uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
# 2️⃣ Install Python for MkDocs build
|
- name: Build Docker Image
|
||||||
- name: Install Python
|
run: docker build -t mkdocs-builder -f ci/mkdocs/Dockerfile .
|
||||||
|
|
||||||
|
- name: Build Static Site
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
docker run --rm -v $(pwd):/docs mkdocs-builder build
|
||||||
apt-get install -y python3 python3-venv python3-pip
|
|
||||||
|
|
||||||
# 3️⃣ List repo files (debug)
|
- name: Deploy to Branch
|
||||||
- name: List repo files
|
|
||||||
run: ls -R "${{ github.workspace }}"
|
|
||||||
|
|
||||||
# 4️⃣ Build MkDocs site locally
|
|
||||||
- name: Build MkDocs site
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m venv .venv
|
# Configure Git
|
||||||
.venv/bin/pip install --upgrade pip
|
git config user.name "gitea-actions[bot]"
|
||||||
.venv/bin/pip install -r ci/mkdocs/requirements.txt
|
git config user.email "actions@noreply.gitea.io"
|
||||||
.venv/bin/mkdocs build --clean --site-dir site_output
|
|
||||||
|
# Move site files to a temporary location
|
||||||
# 5️⃣ Install Docker CLI so we can copy to volume
|
cp -r site /tmp/site_build
|
||||||
- name: Install Docker CLI
|
|
||||||
run: |
|
# Switch to/create the deployment branch
|
||||||
apt-get update
|
git checkout --orphan docs-static
|
||||||
apt-get install -y ca-certificates curl gnupg lsb-release
|
git rm -rf .
|
||||||
install -m 0755 -d /etc/apt/keyrings
|
|
||||||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
# Move files back and commit
|
||||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
cp -r /tmp/site_build/. .
|
||||||
echo \
|
git add .
|
||||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
|
git commit -m "Automated MkDocs build: ${GITEA_SHA}"
|
||||||
https://download.docker.com/linux/debian $(lsb_release -cs) stable" | \
|
|
||||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
# Push back to Gitea (Requires write permissions)
|
||||||
apt-get update
|
git push origin docs-static --force
|
||||||
apt-get install -y docker-ce-cli
|
|
||||||
|
|
||||||
# 6️⃣ Copy the site output into notes_public Docker volume
|
|
||||||
- name: Copy site to notes_public volume
|
|
||||||
run: |
|
|
||||||
docker run --rm \
|
|
||||||
-v notes_public:/public \
|
|
||||||
-v "${{ github.workspace }}/site_output:/tmp/site" \
|
|
||||||
alpine sh -c "cp -r /tmp/site/* /public/"
|
|
||||||
|
|
||||||
# 7️⃣ Optional: Verify files in volume
|
|
||||||
- name: List notes_public volume
|
|
||||||
run: |
|
|
||||||
docker run --rm -v notes_public:/data alpine ls -la /data
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
FROM python:3.13-slim
|
FROM python:3.13-slim
|
||||||
|
|
||||||
WORKDIR /work
|
WORKDIR /docs
|
||||||
|
|
||||||
COPY requirements.txt /tmp/requirements.txt
|
RUN pip install --no-cache-dir \
|
||||||
|
mkdocs \
|
||||||
|
mkdocs-material \
|
||||||
|
mkdocs-minify-plugin
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
ENTRYPOINT ["mkdocs"]
|
||||||
|
|||||||
Reference in New Issue
Block a user