name: Update README

permissions:
  contents: write

on:
  push:
    branches:
      - '**'

jobs:
  readme:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5
      - name: Run doc2readme
        uses: docker://codeberg.org/msrd0/cargo-doc2readme
        with:
          entrypoint: cargo
          args: doc2readme
      - name: Commit updated README
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add README.md
          git diff --cached --quiet || git commit -m "docs: update README" && git push
