name: Documentation
on:
push:
branches: [docs]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
name: Build and Deploy Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build documentation
run: cargo doc --no-deps --document-private-items
- name: Prepare docs for deployment
run: |
mkdir -p target/github-pages
# Copy the contents of target/doc directly to target/github-pages
cp -r target/doc/* target/github-pages/
# Create a simple landing page that redirects to the API docs
cat > target/github-pages/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Project Version Documentation</title>
<meta http-equiv="refresh" content="0; url=project_version/index.html">
</head>
<body>
<p>Redirecting to <a href="project_version/index.html">documentation</a>...</p>
</body>
</html>
EOF
# Create a .nojekyll file to disable GitHub Pages Jekyll processing
touch target/github-pages/.nojekyll
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: "target/github-pages"
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4