name: autogen
on:
  push:
    branches: [master]
    paths:
      - "lua/**.lua"
      - "examples/**.lua"
      - ".stylua.toml"
      - "README.md"

# Cancel any in-progress CI runs for a PR if it is updated
concurrency:
  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
  cancel-in-progress: true

jobs:
  autogen:
    name: "(vimdoc|formating)"
    runs-on: ubuntu-20.04
    timeout-minutes: 10
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v2
      - name: Generate docs with panvimdoc
        uses: kdheepak/panvimdoc@v2.7.1
        with:
          vimdoc: lualine
          description: fast and easy to configure statusline plugin for neovim
      - name: Apply stylua
        uses: JohnnyMorganz/stylua-action@1.0.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --config-path=.stylua.toml lua/ examples/
          version: 0.14.1
      - name: Push changes
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_user_name: github-actions[bot]
          commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
          commit_message: "chore: autogen (vimdocs+formating)"
          branch: ${{ github.head_ref }}
          file_pattern: lua/ examples/ doc/lualine.txt
