Skip to content

Sync latest and multiple improvements (#738) #12

Sync latest and multiple improvements (#738)

Sync latest and multiple improvements (#738) #12

name: Build and Deploy Site
on:
push:
branches: [ markdown ]
workflow_dispatch:
inputs:
target_branches:
description: 'Comma-separated list of branches to build (e.g., markdown,main)'
required: false
default: 'markdown'
type: string
env:
# Default branches - can be overridden by repository variables
BUILD_BRANCHES: 'markdown'
jobs:
build-html:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for branch operations
- name: Run make build
run: |
make build
- name: Verify build output
run: |
echo "Build output contents:"
ls -la output/
echo "HTML files found:"
find output/ -name "*.html" | head -10
- name: Archive HTML
id: archive-html
uses: actions/upload-artifact@v4
with:
name: html
path: output
compression-level: 9
if-no-files-found: error
retention-days: 7
deploy-to-staging:
runs-on: ubuntu-latest
needs: build-html
steps:
- name: Checkout staging
uses: actions/checkout@v5
with:
persist-credentials: true # Needed to commit and push later
ref: asf-staging
- name: Reset HTML
run: |
rm -rf *
- name: Download HTML artifact
uses: actions/download-artifact@v5
with:
name: html
- name: List files
run: ls -la
- name: Restore files
run: |
git restore .htaccess
git restore .asf.yaml
- name: Commit and push HTML
env:
COMMIT_MSG: |
Updated asf staging from GHA workflow run ${{ github.run_id }}
Commit: https://github.com/apache/kafka-site/commit/${{ github.sha }}
GitHub Run: https://github.com/apache/kafka-site/actions/runs/${{ github.run_id }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git diff --quiet && git diff --staged --quiet || git commit -m "$COMMIT_MSG"
git push
- name: Create deployment summary
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Source Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Target Branch**: asf-staging" >> $GITHUB_STEP_SUMMARY
echo "- **Build Time**: $(date)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Build Output" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
ls -la output/ 2>/dev/null || echo "No output directory found" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY