name: Validate PR Title

# thank you ben limmer for this workflow:
# https://github.com/blimmer/semantic-release-demo-2/blob/main/.github/workflows/lint-pr.yml

on:
    pull_request_target:
        types:
            - opened
            - reopened
            - edited
            - synchronize

jobs:
    main:
        runs-on: ubuntu-latest
        steps:
            - uses: amannn/action-semantic-pull-request@v3.2.6
              env:
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
            - name: Post Conventional Commit Comment (on failure)
              uses: jungwinter/comment@v1
              id: conventional-commit-help
              with:
                  type: create
                  issue_number: ${{ github.event.pull_request.number }}
                  token: ${{ secrets.GITHUB_TOKEN }}
                  body: |
                      Your pull request title did not conform to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standards. Our upcoming automated release pipeline will automatically determine
                      the proper release version based on your pull request title.
                      **Cheat Sheet**
                      - feat: A new feature
                      - fix: A bug fix
                      - docs: Documentation only changes
                      - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
                      - refactor: A code change that neither fixes a bug nor adds a feature
                      - perf: A code change that improves performance
                      - test: Adding missing tests or correcting existing tests
                      - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
                      - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
                      - chore: Other changes that don't modify src or test files
                      - revert: Reverts a previous commit
              if: ${{ failure() }}
