ci: build slides via Forgejo Actions runner
Some checks failed
Build slides / build (push) Failing after 1m5s
Some checks failed
Build slides / build (push) Failing after 1m5s
Adds .forgejo/workflows/build-slides.yml triggering on push to main and manual dispatch. Job runs in node:20-bookworm-slim, installs marp-cli + python3, mounts /srv/slides/html into /output, and invokes build-slides.sh with OUTPUT_DIR=/output. build-slides.sh now honors OUTPUT_DIR/SLIDES_TITLE/REPO_WEB_URL env overrides (defaults preserve local-dev behavior), wipes stale .html before each build, and regenerates a styled index.html listing every deck — replacing the equivalent logic from the old webhook update.sh. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c6a284ee1f
commit
90598056d4
2 changed files with 67 additions and 9 deletions
29
.forgejo/workflows/build-slides.yml
Normal file
29
.forgejo/workflows/build-slides.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
name: Build slides
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: self-hosted
|
||||||
|
container:
|
||||||
|
image: node:20-bookworm-slim
|
||||||
|
volumes:
|
||||||
|
- /srv/slides/html:/output
|
||||||
|
env:
|
||||||
|
OUTPUT_DIR: /output
|
||||||
|
steps:
|
||||||
|
- name: Install build dependencies
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y --no-install-recommends git python3 ca-certificates
|
||||||
|
npm install -g @marp-team/marp-cli
|
||||||
|
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build slides into /output
|
||||||
|
run: bash build-slides.sh
|
||||||
|
|
@ -2,7 +2,14 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
OUTPUT_DIR="$REPO_ROOT/slides"
|
OUTPUT_DIR="${OUTPUT_DIR:-$REPO_ROOT/slides}"
|
||||||
|
SLIDES_TITLE="${SLIDES_TITLE:-MakerFLOSS Slides}"
|
||||||
|
REPO_WEB_URL="${REPO_WEB_URL:-https://forgejo.makerfloss.eu/sjat/MakerFLOSS}"
|
||||||
|
|
||||||
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
|
# Wipe previously built slides so deleted/de-tagged .md files disappear.
|
||||||
|
find "$OUTPUT_DIR" -maxdepth 1 -name "*.html" -delete
|
||||||
|
|
||||||
# Find all markdown files with marp: true frontmatter
|
# Find all markdown files with marp: true frontmatter
|
||||||
SLIDES=()
|
SLIDES=()
|
||||||
|
|
@ -18,7 +25,7 @@ fi
|
||||||
echo "Found ${#SLIDES[@]} presentation(s):"
|
echo "Found ${#SLIDES[@]} presentation(s):"
|
||||||
printf ' %s\n' "${SLIDES[@]}"
|
printf ' %s\n' "${SLIDES[@]}"
|
||||||
|
|
||||||
# Create temp output directory for Docker
|
# Create temp output directory for Docker fallback
|
||||||
TEMP_OUTPUT=$(mktemp -d)
|
TEMP_OUTPUT=$(mktemp -d)
|
||||||
chmod 777 "$TEMP_OUTPUT"
|
chmod 777 "$TEMP_OUTPUT"
|
||||||
trap "rm -rf '$TEMP_OUTPUT'" EXIT
|
trap "rm -rf '$TEMP_OUTPUT'" EXIT
|
||||||
|
|
@ -27,7 +34,6 @@ if command -v marp &>/dev/null; then
|
||||||
marp --html --output "$OUTPUT_DIR/" "${SLIDES[@]}"
|
marp --html --output "$OUTPUT_DIR/" "${SLIDES[@]}"
|
||||||
else
|
else
|
||||||
echo "marp not found locally — using Docker (marpteam/marp-cli)..."
|
echo "marp not found locally — using Docker (marpteam/marp-cli)..."
|
||||||
# Process each slide individually in Docker
|
|
||||||
for slide in "${SLIDES[@]}"; do
|
for slide in "${SLIDES[@]}"; do
|
||||||
REL_SLIDE="${slide#${REPO_ROOT}/}"
|
REL_SLIDE="${slide#${REPO_ROOT}/}"
|
||||||
BASENAME=$(basename "${slide%.*}")
|
BASENAME=$(basename "${slide%.*}")
|
||||||
|
|
@ -36,13 +42,8 @@ else
|
||||||
-v "$TEMP_OUTPUT":/home/marp/output \
|
-v "$TEMP_OUTPUT":/home/marp/output \
|
||||||
marpteam/marp-cli --html --output "/home/marp/output/${BASENAME}.html" "$REL_SLIDE"
|
marpteam/marp-cli --html --output "/home/marp/output/${BASENAME}.html" "$REL_SLIDE"
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure output directory exists
|
|
||||||
mkdir -p "$OUTPUT_DIR"
|
|
||||||
|
|
||||||
# Copy generated HTML files to final output directory
|
|
||||||
cp "$TEMP_OUTPUT"/*.html "$OUTPUT_DIR/" 2>/dev/null || true
|
cp "$TEMP_OUTPUT"/*.html "$OUTPUT_DIR/" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Inject mermaid.js into any HTML that contains mermaid code blocks.
|
# Inject mermaid.js into any HTML that contains mermaid code blocks.
|
||||||
# Marp emits fenced mermaid blocks as <pre><code class="language-mermaid">.
|
# Marp emits fenced mermaid blocks as <pre><code class="language-mermaid">.
|
||||||
|
|
@ -90,4 +91,32 @@ else
|
||||||
echo "Warning: python3 not found — skipping mermaid injection"
|
echo "Warning: python3 not found — skipping mermaid injection"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Regenerate index.html listing every built deck.
|
||||||
|
INDEX="$OUTPUT_DIR/index.html"
|
||||||
|
{
|
||||||
|
printf '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
|
||||||
|
printf '<meta name="viewport" content="width=device-width,initial-scale=1">'
|
||||||
|
printf '<title>%s</title>' "$SLIDES_TITLE"
|
||||||
|
printf '<style>'
|
||||||
|
printf 'body{font-family:sans-serif;max-width:700px;margin:3rem auto;padding:0 1.5rem;background:#fafafa;}'
|
||||||
|
printf 'h1{font-size:1.6rem;margin-bottom:.25rem;}p.sub{color:#666;margin-top:0;}'
|
||||||
|
printf 'ul{list-style:none;padding:0;margin-top:2rem;}'
|
||||||
|
printf 'li{border:1px solid #e0e0e0;border-radius:6px;margin:.75rem 0;background:#fff;}'
|
||||||
|
printf 'li a{display:block;padding:1rem 1.25rem;text-decoration:none;color:#1a1a1a;font-size:1.05rem;}'
|
||||||
|
printf 'li a:hover{background:#f0f4ff;border-radius:6px;}'
|
||||||
|
printf 'footer{margin-top:3rem;color:#aaa;font-size:.8rem;}'
|
||||||
|
printf '</style></head><body>'
|
||||||
|
printf '<h1>%s</h1>' "$SLIDES_TITLE"
|
||||||
|
printf '<p class="sub">Built from <a href="%s">%s</a></p>' \
|
||||||
|
"$REPO_WEB_URL" "${REPO_WEB_URL#https://}"
|
||||||
|
printf '<ul>'
|
||||||
|
find "$OUTPUT_DIR" -maxdepth 1 -name "*.html" ! -name "index.html" | sort | while IFS= read -r html; do
|
||||||
|
name=$(basename "$html" .html)
|
||||||
|
printf '<li><a href="%s">%s</a></li>' "$(basename "$html")" "$name"
|
||||||
|
done
|
||||||
|
printf '</ul>'
|
||||||
|
printf '<footer>Last built: %s · <a href="https://marp.app">Marp</a></footer>' "$(date -Iseconds)"
|
||||||
|
printf '</body></html>'
|
||||||
|
} > "$INDEX"
|
||||||
|
|
||||||
echo "Done — slides in $OUTPUT_DIR/"
|
echo "Done — slides in $OUTPUT_DIR/"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue