name: Documentation
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: docs-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: prefix-dev/setup-pixi@v0.9.4
with:
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
environments: docs
- name: Add cargo bin to PATH
run: echo "${{ runner.temp }}/.cargo/bin" >> "$GITHUB_PATH"
- name: Build documentation
run: pixi run -e docs docbld
env:
CARGO_HOME: ${{ runner.temp }}/.cargo
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs/build
retention-days: 14
- name: Ensure Cloudflare Pages project exists
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
github.event_name == 'workflow_dispatch'
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: npx wrangler@3 pages project create eindir-docs --production-branch=main || true
- name: Deploy to Cloudflare Pages
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
github.event_name == 'workflow_dispatch'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy docs/build --project-name=eindir-docs --branch=main