diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml new file mode 100644 index 0000000..5767c9e --- /dev/null +++ b/.github/workflows/check-pr-title.yml @@ -0,0 +1,27 @@ +name: Check PR title + +on: + workflow_call: + +defaults: + run: + shell: bash + +jobs: + check_title: + runs-on: ubuntu-latest + + steps: + - uses: ytanikin/pr-conventional-commits@fda730cb152c05a849d6d84325e50c6182d9d1e9 # 1.5.1 + with: + task_types: '["build", "feat", "fix", "docs", "test", "ci", "style", "refactor", "perf", "chore"]' + add_label: false + + - name: Check if title starts with upper-case letter + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + if [[ ! "${PR_TITLE}" =~ ^[a-z]+:\ [\[A-Z] ]]; then + echo "Error: PR title must start with an upper-case letter." + exit 1 + fi diff --git a/.github/workflows/test-check-pr-title.yml b/.github/workflows/test-check-pr-title.yml new file mode 100644 index 0000000..2dcdbde --- /dev/null +++ b/.github/workflows/test-check-pr-title.yml @@ -0,0 +1,8 @@ +on: + pull_request: + types: [opened, edited, reopened, synchronize] + workflow_dispatch: + +jobs: + test-check-pr-title: + uses: ./.github/workflows/check-pr-title.yml diff --git a/README.md b/README.md index 9d1e068..fa9ba58 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Reusable workflows and actions for XRPLF repos ## Available Reusable Workflows +- `check-pr-title.yml`: Checks the title of Pull Requests against a specified pattern. - `pre-commit.yml`: Runs `pre-commit` checks on code changes. - `pre-commit-autoupdate.yml`: Runs `pre-commit autoupdate` to update pre-commit hooks.