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

chore: add PR title check workflow #13872

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions .github/workflows/check-convential-commit-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check Conventional Commit PR Title

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

jobs:
check-pr-title:
runs-on: ubuntu-latest
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: amplify-js
- name: Generate Regex and Check PR title
working-directory: ./amplify-js
run: |
regex=$(./scripts/generate-conventional-commit-regex.sh)
if [[ "$PR_TITLE" =~ $regex ]]; then
echo "✅ PR title '$PR_TITLE' is valid"
exit 0
else
echo "❌ PR title '$PR_TITLE' is invalid"
echo "It should match the pattern: $regex"
exit 1
fi
10 changes: 10 additions & 0 deletions scripts/generate-conventional-commit-regex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Get the list of directory names under ./packages
scopes=$(ls -d ./packages/*/ 2>/dev/null | xargs -n 1 basename | tr '\n' '|' | sed 's/|$//')

# Generate the regular expression
regex="^(feat|fix|docs|style|refactor|perf|test|chore|revert|release)(\(($scopes|required)\))?: .+$"
Copy link
Member

@ashika112 ashika112 Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our default commits post release is chore (release) we should update regex to enable that as well.

Also, we have in our runbook hot-fix/ which does not really conform to this. Maybe we should update the runbook or allow for it for now. Its for branch nvm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the merging release back to main PR has hardedcoded name as chore: Merge release into main:

gh pr create -B main -H $TEMP_BRANCH_NAME --title 'chore: Merge release into main' --body 'Merge the recently completed release back into the main development branch. Generated by the callable-npm-publish-release workflow.'


# Output the generated regex
echo "$regex";
Loading