name: Docs
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: deploy
cancel-in-progress: false
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Configure cache
uses: Swatinem/rust-cache@v2
- name: Setup pages
id: pages
uses: actions/configure-pages@v5
- name: Clean docs folder
run: cargo clean --doc
- name: Build docs
run: cargo doc --no-deps
- name: Setup docs directory
run: |
mkdir -p public
cp -r docs/* public/
mkdir -p public/api/rustdoc
cp -r target/doc/* public/api/rustdoc/
# Create CNAME file for custom domain
echo "athena-cli.andyhoang.me" > public/CNAME
# Create index.html at the root to properly redirect
cat > public/index.html <<EOL
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0;url=api/rustdoc/athena_cli/index.html">
<title>Athena CLI</title>
</head>
<body>
<p>Redirecting to <a href="api/rustdoc/athena_cli/index.html">documentation</a>...</p>
</body>
</html>
EOL
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './public'
deploy:
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4