From e56915e61828a7aed2a8db7eda0a7461f5ba351c Mon Sep 17 00:00:00 2001 From: amc-nu Date: Wed, 22 Oct 2025 10:46:00 +0900 Subject: [PATCH 1/4] feat: add check pr title ci workflow file Signed-off-by: amc-nu --- .github/workflows/check-pr-title.yml | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/check-pr-title.yml diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml new file mode 100644 index 0000000..aa7de4c --- /dev/null +++ b/.github/workflows/check-pr-title.yml @@ -0,0 +1,34 @@ +name: Check PR Title Format + +on: + pull_request: + types: [opened, reopened, synchronize, edited] + branches: + - develop + workflow_call: + outputs: + is_pr_title_valid: + description: "Is the PR title format correct" + value: ${{ jobs.check-pr-title.outputs.is_pr_title_valid }} + +jobs: + check-pr-title: + runs-on: self-hosted + outputs: + is_pr_title_valid: ${{ steps.check-pr-title.outputs.is_pr_title_valid }} + steps: + - name: Check PR Title + id: check-pr-title + uses: actions/github-script@v7 + with: + script: | + const prTitle = context.payload.pull_request.title; + const pattern = /^\[[^\]]+\]\[[^\]]+\] .+/; + const isValid = pattern.test(prTitle); + core.setOutput('is_pr_title_valid', isValid.toString()); + + if (!isValid) { + core.setFailed(`❌ PR title "${prTitle}" does not match the required pattern. Make sure it starts with two sets of square brackets and a summary.`); + } else { + core.info(`✅ PR title "${prTitle}" matches the pattern.`); + } From 994e3e8636dc3e80c42b357423f8476a61e4194e Mon Sep 17 00:00:00 2001 From: amc-nu Date: Wed, 22 Oct 2025 10:46:47 +0900 Subject: [PATCH 2/4] docs: add how to use check-pr-title workflow Signed-off-by: amc-nu --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index affbe50..0aebf5e 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,12 @@ jobs: 1. 利用したいレポジトリのルートに`.pre-commit-config.yaml`を配置する 1. pip3 install pre-commit 1. pre-commit install + +### Check PR Title + +To enable this workflow, add the `check-pr-title.yml` file to your repository under the `.github/workflows/` directory. +Ensure that GitHub Actions are enabled in your repository. When a pull request is opened, edited, or synchronized, the workflow will automatically check whether the PR title follows the Semantic PR naming convention. + +このワークフローを有効にするには、リポジトリの `.github/workflows/` ディレクトリに `check-pr-title.yml` ファイルを追加してください。 +また、リポジトリで GitHub Actions が有効になっていることを確認してください。 +プルリクエストが作成・編集・同期された際に、ワークフローが自動的にタイトルをチェックし、Semantic PR の命名規則に従っているかを確認します。 From 823ea4b1ef44abb3b5c2d8567a3f90c3ec71ab12 Mon Sep 17 00:00:00 2001 From: amc-nu Date: Wed, 22 Oct 2025 10:51:59 +0900 Subject: [PATCH 3/4] chore: add master branch to the check Signed-off-by: amc-nu --- .github/workflows/check-pr-title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml index aa7de4c..cb53d91 100644 --- a/.github/workflows/check-pr-title.yml +++ b/.github/workflows/check-pr-title.yml @@ -4,7 +4,7 @@ on: pull_request: types: [opened, reopened, synchronize, edited] branches: - - develop + - master workflow_call: outputs: is_pr_title_valid: From 7f83b36a6ab67019eec59c76ce89f4f4c634045d Mon Sep 17 00:00:00 2001 From: amc-nu Date: Wed, 22 Oct 2025 10:52:25 +0900 Subject: [PATCH 4/4] chore: add descriptive error message Signed-off-by: amc-nu --- .github/workflows/check-pr-title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml index cb53d91..819a849 100644 --- a/.github/workflows/check-pr-title.yml +++ b/.github/workflows/check-pr-title.yml @@ -28,7 +28,7 @@ jobs: core.setOutput('is_pr_title_valid', isValid.toString()); if (!isValid) { - core.setFailed(`❌ PR title "${prTitle}" does not match the required pattern. Make sure it starts with two sets of square brackets and a summary.`); + core.setFailed(`❌ PR title "${prTitle}" does not match the required pattern. Make sure it follow Semantic PR definition '[category][scope] description'.`); } else { core.info(`✅ PR title "${prTitle}" matches the pattern.`); }