name: docs

on:
  push:
    paths:
      - "docs/**"
    branches:
      - main
  pull_request:
    paths:
      - "docs/**"
    branches:
      - main

concurrency:
  group: docs-${{ github.head_ref }}
  cancel-in-progress: true

env:
  MISE_EXPERIMENTAL: 1

jobs:
  docs:
    if: github.repository == 'jdx/mise'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # for lastUpdated
      - uses: jdx/mise-action@v2
        with:
          install_args: bun
          working_directory: docs
      - run: bun install
        working-directory: docs
      - run: bun run docs:build
        working-directory: docs
      - if: github.event_name == 'push' && github.ref == 'refs/heads/main'
        run: mise run release-docs
        working-directory: docs
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }}
