This file contains 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: Build and Deploy Jekyll and Doxygen Documentation | |
on: | |
push: | |
branches: | |
- gh-pages | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
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 | |
fetch-depth: 0 | |
# 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: . | |
destination: ./_site | |
# Install Doxygen and Dependencies | |
- name: Install Doxygen and Dependencies | |
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz texlive | |
# Generate Doxygen Documentation | |
- name: Generate Doxygen Documentation | |
run: | | |
branches=("master:core" "duo" "handle" "orbit" "gloves" "desktop" "spark" "chromadeck") | |
mkdir -p docs # Ensure the docs directory exists | |
for item in "${branches[@]}"; do | |
IFS=':' read -r branch dest <<< "$item" | |
dest="${dest:-$branch}" | |
# Create a worktree for each branch in a separate directory | |
echo "Setting up worktree for branch: $branch" | |
git worktree add --detach worktree/$branch $branch | |
# Change directory to the worktree | |
cd worktree/$branch | |
# Ensure the output directory exists in the docs folder | |
mkdir -p ../../docs/$dest | |
# Change OUTPUT_DIRECTORY in Doxyfile for each branch | |
echo "Adjusting Doxyfile for branch: $branch" | |
sed -i "s|OUTPUT_DIRECTORY *=.*|OUTPUT_DIRECTORY = ../../docs/$dest|" Doxyfile | |
echo "Running Doxygen for branch: $branch" | |
doxygen Doxyfile || { echo "Doxygen failed for branch: $branch"; exit 1; } | |
echo "Generated docs for $branch in docs/$dest" | |
# Return to the root directory | |
cd ../.. | |
# Remove the worktree after processing | |
git worktree remove worktree/$branch -f | |
done | |
# Deploy to GitHub Pages | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./_site | |
publish_branch: gh-pages | |
keep_files: true | |