name: autoreadme

on:
  # Generate README.md if templates/docs were modified in default branches
  push:
    branches:
      - trunk
    paths:
      - "README.tpl"
      - "**lib.rs"
      - "**readme.yml"

jobs:
  readme:
    name: Generate README
    runs-on: ubuntu-latest
    steps: 
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true 
      - name: Install cargo-readme
        run: cargo install cargo-readme
      - name: Run cargo-readme
        run: cargo readme > README.md
      - name: Commit generated README
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: 'docs: generate readme from template :robot:'
          file_pattern: README.md
