Skip to content
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check PR Title Format

on:
pull_request:
types: [opened, reopened, synchronize, edited]
branches:
- master
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 = /^\[[^\]]+\]\[[^\]]+\] .+/;
Comment thread
amc-nu marked this conversation as resolved.
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 follow Semantic PR definition '[category][scope] description'.`);
} else {
core.info(`✅ PR title "${prTitle}" matches the pattern.`);
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 の命名規則に従っているかを確認します。
Loading