Deploy Documentation (Bazel) to Netcup #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Documentation (Bazel) to Netcup | |
# Bazel-native workflow for building and deploying documentation site | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "docs-site/**" | |
workflow_dispatch: | |
inputs: | |
force_deploy: | |
description: "Force deployment even if no docs-site changes" | |
required: false | |
default: "false" | |
jobs: | |
bazel-build-and-deploy: | |
runs-on: ubuntu-latest | |
# Only run on main branch to prevent accidental deployments | |
if: github.ref == 'refs/heads/main' | |
env: | |
NETCUP_URI: ${{ secrets.NETCUP_URI }} | |
NETCUP_USER: ${{ secrets.NETCUP_USER }} | |
NETCUP_PASSWORD: ${{ secrets.NETCUP_PASSWORD }} | |
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Bazel | |
uses: bazel-contrib/setup-bazel@0.8.5 | |
with: | |
bazelisk-cache: true | |
disk-cache: ${{ github.workflow }} | |
repository-cache: true | |
- name: Build and validate documentation site | |
run: | | |
# Run comprehensive validation and build | |
echo "🧪 Running documentation validation tests..." | |
bazel test //docs-site:docs_tests | |
echo "📦 Building deployment bundle..." | |
bazel build //docs-site:deployment_bundle | |
# Extract deployment bundle for FTP upload | |
echo "📂 Extracting deployment bundle..." | |
mkdir -p deployment_temp | |
cd deployment_temp | |
tar -xzf ../bazel-bin/docs-site/docs_deployment.tar.gz | |
# Verify deployment content | |
echo "✅ Verifying deployment content..." | |
ls -la . | |
echo "📄 Documentation site preview:" | |
head -5 index.html | grep -E "(title|h1)" || echo "Basic HTML structure verified" | |
# Check file size (should be reasonable) | |
SIZE=$(wc -c < index.html) | |
echo "📊 Site size: ${SIZE} bytes" | |
if [ $SIZE -lt 1000 ]; then | |
echo "❌ Warning: Site seems too small" | |
exit 1 | |
elif [ $SIZE -gt 100000 ]; then | |
echo "❌ Warning: Site seems too large" | |
exit 1 | |
else | |
echo "✅ Site size is reasonable" | |
fi | |
- name: Deploy to Netcup hosting | |
# Only deploy if secrets are available | |
if: env.NETCUP_URI != '' && env.NETCUP_USER != '' && env.NETCUP_PASSWORD != '' | |
uses: SamKirkland/FTP-Deploy-Action@v4.3.4 | |
with: | |
server: ${{ env.NETCUP_URI }} | |
username: ${{ env.NETCUP_USER }} | |
password: ${{ env.NETCUP_PASSWORD }} | |
local-dir: ./deployment_temp/ | |
server-dir: / | |
exclude: | | |
**/.git* | |
**/.git*/** | |
**/node_modules/** | |
**/.DS_Store | |
**/Thumbs.db | |
- name: Skip deployment (secrets not configured) | |
if: env.NETCUP_URI == '' || env.NETCUP_USER == '' || env.NETCUP_PASSWORD == '' | |
run: | | |
echo "⚠️ Skipping deployment - Netcup secrets not configured" | |
echo "📦 Bazel build completed successfully, but deployment requires secrets" | |
- name: Purge Cloudflare cache (optional) | |
if: env.CLOUDFLARE_ZONE_ID != '' | |
uses: jakejarvis/cloudflare-purge-action@master | |
with: | |
zone: ${{ env.CLOUDFLARE_ZONE_ID }} | |
token: ${{ env.CLOUDFLARE_TOKEN }} |