Skip to content

Workflow file for this run

name: Build and Deploy Jekyll and Doxygen Documentation
on:
push:
branches:
- gh-pages
permissions:
contents: write
pages: write
id-token: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout the gh-pages branch to have access to the existing docs directory
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages # Checkout to a specific directory to separate it from source
# Setup Pages environment and dependencies
- name: Setup Pages
uses: actions/configure-pages@v5
# Build Jekyll Site
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: gh-pages/docs
destination: gh-pages/_site
# Install Doxygen and Dependencies
- name: Install Doxygen and Dependencies
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz
# Generate Doxygen Documentation
- name: Generate Doxygen Documentation
run: |
# Define the branches and their corresponding doc folders
branches=("master:core" "duo" "handle" "orbit" "gloves" "desktop" "spark" "chromadeck")
mkdir -p gh-pages/docs # Ensure the docs directory exists
# Iterate over each branch and generate documentation
for item in "${branches[@]}"; do
IFS=':' read -r branch dest <<< "$item"
dest="${dest:-$branch}"
# Check if the branch exists on the remote
if git ls-remote --heads origin $branch | grep -q $branch; then
echo "Processing branch: $branch"
# Use a temporary directory for each branch to avoid conflicts
mkdir -p temp/$branch
git worktree add temp/$branch origin/$branch
# Change directory to the worktree
cd temp/$branch
# Ensure the output directory exists in the docs folder
mkdir -p ../../gh-pages/docs/$dest
# Adjust the Doxyfile to set the output directory
echo "Adjusting Doxyfile for branch: $branch"
sed -i "s|OUTPUT_DIRECTORY *=.*|OUTPUT_DIRECTORY = ../../gh-pages/docs/$dest|" Doxyfile
# Run Doxygen to generate the documentation
echo "Running Doxygen for branch: $branch"
doxygen Doxyfile || { echo "Doxygen failed for branch: $branch"; exit 1; }
# Return to the root directory
cd ../..
# Clean up the worktree
git worktree remove temp/$branch -f
else
echo "Branch $branch does not exist on the remote."
fi
done
# Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: gh-pages/_site
publish_branch: gh-pages
keep_files: true