Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add semantic-pr #58

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/_semantic_pull_request.yml
Original file line number Diff line number Diff line change
@@ -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;