diff --git a/.github/workflows/_semantic_pull_request.yml b/.github/workflows/_semantic_pull_request.yml new file mode 100644 index 0000000..0f0c7db --- /dev/null +++ b/.github/workflows/_semantic_pull_request.yml @@ -0,0 +1,53 @@ +name: Validate PR title + +on: + workflow_call: + +defaults: + run: + shell: bash -x -e -u -o pipefail {0} + +permissions: + pull-requests: read + +jobs: + semantic-pull-request: + # This job validates that the title of this pull-request matches the + # [conventional-commit-types](https://github.com/commitizen/conventional-commit-types/blob/master/index.json). + # We use squash-based merging, so the PRs semantic title will become + # the squashed commit message's title. + # This allows follow-up actions, like automated changelog-generation. + # Also, standardized and beautiful commit messages! + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Semantic PR title + uses: amannn/action-semantic-pull-request@v5 + with: + types: | + feat + fix + docs + style + refactor + perf + test + build + ci + chore + revert + + - name: PR title length + if: always() + env: + PR_NUMBER: ${{ github.event.number }} + REPOSITORY: ${{ github.repository }} + run: | + PR=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$REPOSITORY/pulls/$PR_NUMBER) + + test $(echo -E $PR | jq '.title | length') -le 80;