Skip to content

chore: add action to check PR title prefix #2836

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

Merged
merged 3 commits into from
Apr 6, 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
33 changes: 33 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PR

on:
pull_request:
types: [opened, edited, synchronize]

jobs:
check-title:
runs-on: ubuntu-latest
steps:
- name: Check PR Title Prefix
id: title-check
uses: actions/github-script@v7
with:
script: |
const titlePrefixes = ["feat", "fix", "break", "chore"];
const title = context.payload.pull_request.title.toLowerCase();
const titleHasValidPrefix = titlePrefixes.some((prefix) => title.startsWith(`${prefix}:`));
if (!titleHasValidPrefix) { process.exit(-1); }

- uses: thollander/actions-comment-pull-request@v2
if: success()
with:
message: |
✅ PR title meet the requirements.
comment_tag: PR title check result

- uses: thollander/actions-comment-pull-request@v2
if: failure()
with:
message: |
🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'.
comment_tag: PR title check result
Loading