Fix workflow: Use isolated git clones instead of host mounts for
Some checks failed
deploy-docs / build-and-deploy (push) Failing after 26s
Some checks failed
deploy-docs / build-and-deploy (push) Failing after 26s
build
This commit is contained in:
@@ -9,36 +9,55 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: hugomods/hugo:latest
|
||||
# We mount both the existing Hugo site structure and the deployment target
|
||||
options: --user root -v /srv/caddy/sites:/deploy -v /srv/dev/hugo/wiki:/hugo-site
|
||||
# We only mount the deployment target, we DO NOT mount the host's framework directory
|
||||
options: --user root -v /srv/caddy/sites:/deploy
|
||||
|
||||
steps:
|
||||
- name: Checkout Docs Source
|
||||
# 1. Checkout the Framework from Gitea
|
||||
- name: Checkout Hugo Framework
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: wompmacho/hugo-framework
|
||||
path: hugo-site
|
||||
# The default token has access to other repos owned by the user
|
||||
token: ${{ github.token }}
|
||||
submodules: true
|
||||
|
||||
- name: Sync Markdown and Assets to Hugo Site
|
||||
# 2. Checkout the Content
|
||||
- name: Checkout Docs Content
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: docs-content
|
||||
|
||||
# 3. Merge and Build
|
||||
- name: Sync Markdown and Build
|
||||
run: |
|
||||
# Clean the existing content and static in the mounted Hugo site
|
||||
rm -rf /hugo-site/content/*
|
||||
# The static symlink in hugo-site won't work inside the container context
|
||||
# because the path '/srv/docs/public/static' doesn't exist inside the container.
|
||||
# We must replace the symlink with a real folder for the build.
|
||||
rm -f /hugo-site/static
|
||||
mkdir -p /hugo-site/static
|
||||
cd hugo-site
|
||||
|
||||
# Copy the new content from this repo into the Hugo content folder
|
||||
cp -r . /hugo-site/content/
|
||||
# Remove the symlinks that were committed to the framework repo
|
||||
rm -f content static
|
||||
|
||||
# Copy static files if they exist in this repo
|
||||
if [ -d "./static" ]; then
|
||||
cp -r ./static/* /hugo-site/static/
|
||||
# Create real folders
|
||||
mkdir -p content static
|
||||
|
||||
# Copy content from docs-content
|
||||
cp -r ../docs-content/* content/
|
||||
|
||||
# Move static assets if they exist inside the copied content
|
||||
if [ -d "content/static" ]; then
|
||||
cp -r content/static/* static/
|
||||
rm -rf content/static
|
||||
fi
|
||||
|
||||
# Remove Git-related metadata from the content folder
|
||||
rm -rf /hugo-site/content/.git /hugo-site/content/.gitea
|
||||
rm -rf /hugo-site/content/static
|
||||
# Clean git metadata
|
||||
rm -rf content/.git content/.gitea
|
||||
|
||||
# Build the site
|
||||
hugo --minify --destination public
|
||||
|
||||
- name: Build and Deploy Hugo
|
||||
# 4. Deploy to Caddy
|
||||
- name: Deploy to Caddy
|
||||
run: |
|
||||
cd /hugo-site
|
||||
hugo --minify --destination /deploy/wiki
|
||||
mkdir -p /deploy/wiki
|
||||
rm -rf /deploy/wiki/*
|
||||
cp -r hugo-site/public/* /deploy/wiki/
|
||||
|
||||
Reference in New Issue
Block a user