name: generate

on:
  push:
    branches:
      - 'main'
    paths:
      - '.github/workflows/generate.yml'
      - pkg/config/config.go
      - CONTRIBUTING.md
      - USERS.md

permissions:
  contents: read

jobs:
  docs:
    permissions:
      contents: write  # for stefanzweifel/git-auto-commit-action to push code in repo
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3
        with:
          token: ${{ secrets.GH_PAT }}
      - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3
        with:
          go-version: '>=1.19.2'
          cache: true
      - uses: arduino/setup-task@d665c6beebae46ff3f699d7b2fd3f1959de7153c # v1
      - run: task docs:generate
      - run: task schema:generate
      - uses: stefanzweifel/git-auto-commit-action@fd157da78fa13d9383e5580d1fd1184d89554b51 # v4
        with:
          commit_message: "chore: docs auto-update"
          branch: main
          commit_user_name: actions-user
          commit_user_email: actions@github.com
          commit_author: actions-user <actions@github.com>
