name: Upload documentation to GitHub Pages

on:
  push:
    branches:
      - master

# Sets permissions of `GITHUB_TOKEN` to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Rust toolchain
        run: TARGET=x86_64-unknown-linux-gnu sh ./ci/install-rust.sh
      - name: Generate documentation
        run: LIBC_CI=1 sh ci/dox.sh
      - name: Setup Pages
        uses: actions/configure-pages@v2
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: 'target/doc'
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1
