dms #1
@@ -3,7 +3,7 @@ name: Build and Deploy MkDocs
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main # change if needed
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
@@ -12,35 +12,35 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Important for switching branches
|
||||||
|
|
||||||
- name: Build and Extract Site
|
- name: Build and Extract Site
|
||||||
run: |
|
run: |
|
||||||
docker build -t mkdocs-temp -f ci/mkdocs/Dockerfile .
|
docker build -t mkdocs-temp -f ci/mkdocs/Dockerfile .
|
||||||
docker create --name temp-container mkdocs-temp
|
docker create --name temp-container mkdocs-temp
|
||||||
docker cp temp-container:/build/site ./site
|
# Copying content to a folder named 'output_content' to avoid naming collisions
|
||||||
|
docker cp temp-container:/build/site ./output_content
|
||||||
docker rm temp-container
|
docker rm temp-container
|
||||||
|
|
||||||
- name: Deploy to docs-static Branch
|
- name: Deploy to docs-static Branch
|
||||||
run: |
|
run: |
|
||||||
git config user.name "gitea-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "actions@noreply.gitea.io"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
# Move built site somewhere safe
|
# Move built content to a temporary location outside the git tree
|
||||||
mv site /tmp/site_build
|
mv output_content /tmp/site_final
|
||||||
|
|
||||||
# Create orphan branch
|
# Switch to an orphan branch
|
||||||
git checkout --orphan docs-static
|
git checkout --orphan docs-static
|
||||||
|
|
||||||
# Remove tracked files
|
# Completely clear the working directory of all tracked files
|
||||||
git rm -rf . 2>/dev/null || true
|
git rm -rf .
|
||||||
|
|
||||||
# Clean working directory
|
# Copy ONLY the contents of the build folder into the root
|
||||||
rm -rf *
|
cp -r /tmp/site_final/. .
|
||||||
|
|
||||||
# Copy ONLY built output back in
|
|
||||||
cp -r /tmp/site_build/. .
|
|
||||||
|
|
||||||
|
# Add, commit, and force push
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Automated MkDocs build"
|
git commit -m "Automated MkDocs build: $(date)"
|
||||||
|
|
||||||
git push origin docs-static --force
|
git push origin docs-static --force
|
||||||
|
|||||||
Reference in New Issue
Block a user