name: publish_docs

on:
  # ON RELEASE, the commit is not handled by Github Actions
  # release:
  #   types: [created]
  push:
    branches: [main]
jobs:
  publish-docs:
    runs-on: ubuntu-latest
    steps:
      - name: checkout repo content
        uses: actions/checkout@v2

      - name: setup python
        uses: actions/setup-python@v2
        with:
          python-version: "3.9"

      - name: install deps and run automatic documentation
        run: |
          python -m pip install --upgrade pip
          python -m pip install pdoc

      - name: run automatic documentation
        run: |
          python -m pdoc pipewire_python/ --docformat google --output-directory docs/html/ --edit-url pipewire_python=https://github.com/pablodz/pipewire_python/tree/main/pipewire_python/

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          # Optional, but recommended
          # Defaults to "Apply automatic changes"
          commit_message: PDOC-Automatic documentation

          # Optional. Used by `git-commit`.
          # See https://git-scm.com/docs/git-commit#_options
          commit_options: "--no-verify --signoff --allow-empty"

          # Optional glob pattern of files which should be added to the commit
          # Defaults to all (.)
          # See the `pathspec`-documentation for git
          # - https://git-scm.com/docs/git-add#Documentation/git-add.txt-ltpathspecgt82308203
          # - https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec
          file_pattern: docs/*

          # Optional local file path to the repository
          # Defaults to the root of the repository
          # repository: .

          # Optional commit user and author settings
          # commit_user_name: My GitHub Actions Bot # defaults to "GitHub Actions"
          # commit_user_email: my-github-actions-bot@example.org # defaults to "actions@github.com"
          # commit_author: Author <actions@github.com> # defaults to author of the commit that triggered the run

          # Optional tag message
          # Action will create and push a new tag to the remote repository and the defined branch
          # tagging_message: 'v1.0.0'

          # Optional. Used by `git-status`
          # See https://git-scm.com/docs/git-status#_options
          # status_options: '--untracked-files=no'

          # Optional. Used by `git-add`
          # See https://git-scm.com/docs/git-add#_options
          add_options: "-u"

          # Optional. Used by `git-push`
          # See https://git-scm.com/docs/git-push#_options
          # push_options: '--force'

          # Optional. Disable dirty check and always try to create a commit and push
          skip_dirty_check: true

          # Optional. Skip internal call to `git fetch`
          skip_fetch: true

          # Optional. Prevents the shell from expanding filenames.
          # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
          disable_globbing: true
