From 6f6f7e205d699b45e3db0a6253a5a0fa9dc8878c Mon Sep 17 00:00:00 2001 From: Arzianghanchi Date: Wed, 21 Jan 2026 22:30:03 +0000 Subject: [PATCH 1/3] feat: pr title check github shared workflow --- .github/workflows/pr-title-check.yml | 31 +++++++++++ docs/31.pr-title-validation.md | 82 ++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 .github/workflows/pr-title-check.yml create mode 100644 docs/31.pr-title-validation.md diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-check.yml new file mode 100644 index 00000000..91caec22 --- /dev/null +++ b/.github/workflows/pr-title-check.yml @@ -0,0 +1,31 @@ +--- +name: PR Title Validation +on: + workflow_call: + inputs: + regex: + description: "Regex to validate PR title" + required: false + type: string + default: '^(Feat:|feat:|Fix:|fix:|Docs:|docs:|Test:|test:|ci:|refactor:|chore:|revert:) ' + +jobs: + pr-title-check: + runs-on: ubuntu-latest + + steps: + - name: Validate PR title + run: | + echo "PR Title: '${{ github.event.pull_request.title }}'" + + TITLE="${{ github.event.pull_request.title }}" + REGEX="${{ inputs.regex }}" + + if [[ ! "$TITLE" =~ $REGEX ]]; then + echo "::error::Invalid PR title." + echo "::error::Title must start with one of:" + echo "::error::Feat:, feat:, Fix:, fix:, Docs:, docs:, Test:, test:, ci:, refactor:, chore:, revert:" + exit 1 + fi + + echo "PR title is valid ✅"[PR Title Validation Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/pr-title-validation.yml) \ No newline at end of file diff --git a/docs/31.pr-title-validation.md b/docs/31.pr-title-validation.md new file mode 100644 index 00000000..31bf8f8a --- /dev/null +++ b/docs/31.pr-title-validation.md @@ -0,0 +1,82 @@ +## [PR Title Validation Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/pr-title-validation.yml) + +This workflow is used to **validate Pull Request titles** using GitHub Actions. +It enforces a standardized PR title format (for example: `feat:`, `fix:`, `docs:`) to maintain consistency across repositories. + +## Usage + +The PR Title Validation workflow is automatically triggered on Pull Request events such as: + +- opened +- edited +- synchronized +- reopened + +To use this shared workflow, add the following workflow definition to your repository: + +``` +.github/workflows/pr-title-validation.yml +``` + +--- + +## Example Usage + +```yaml +name: PR Validation + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + pr-title-validation: + uses: clouddrove/github-shared-workflows/.github/workflows/pr-title-validation.yml@master + +``` + +--- + +## Example with Custom Regex (Optional) + +You can override the default PR title regex if your repository follows a different convention (for example, enforcing JIRA tickets). + +```yaml +name: PR Validation + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + pr-title-validation: + uses: clouddrove/github-shared-workflows/.github/workflows/pr-title-validation.yml@master + with: + regex: '^(feat|fix|docs|chore|refactor|ci|test)\([A-Z]+-[0-9]+\): ' + +``` + +### Example Valid PR Titles + +``` +feat: add user login flow +fix: resolve memory leak +docs: update README + +``` + +--- + +## Inputs + +| Name | Required | Description | +| --- | --- | --- | +| `regex` | ❌ No | Custom regex to validate PR title format. If not provided, the default prefix-based regex is used. | + +--- + +## Behavior + +- ✅ If the PR title matches the regex → workflow passes +- ❌ If the PR title does **not** match → workflow fails and blocks merge +- ❌ Failure message clearly explains allowed formats \ No newline at end of file From df3af1f4f41f2512d37a96ac664e4b56fdf3c0a4 Mon Sep 17 00:00:00 2001 From: Arzianghanchi Date: Wed, 21 Jan 2026 22:39:14 +0000 Subject: [PATCH 2/3] fix: rename workflow file form pr-title-check.yaml to pr-title-validation.yml --- .github/workflows/{pr-title-check.yml => pr-title-validation.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{pr-title-check.yml => pr-title-validation.yml} (100%) diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-validation.yml similarity index 100% rename from .github/workflows/pr-title-check.yml rename to .github/workflows/pr-title-validation.yml From 70bf15a46115cdb0bb6ffa542c00ca74f10850ed Mon Sep 17 00:00:00 2001 From: Arzianghanchi Date: Wed, 21 Jan 2026 22:51:24 +0000 Subject: [PATCH 3/3] fix: yaml github workflow --- .github/workflows/pr-title-validation.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-title-validation.yml b/.github/workflows/pr-title-validation.yml index 91caec22..06a92007 100644 --- a/.github/workflows/pr-title-validation.yml +++ b/.github/workflows/pr-title-validation.yml @@ -28,4 +28,5 @@ jobs: exit 1 fi - echo "PR title is valid ✅"[PR Title Validation Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/pr-title-validation.yml) \ No newline at end of file + echo "PR title is valid ✅"[PR Title Validation Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/pr-title-validation.yml) +...