Skip to content

Commit 9f95e79

Browse files
committed
ci: replace third-party action with inline conventional-commit regex
The Stainless TS/Python repos restrict GitHub Actions to an allowlist that doesn't include amannn/action-semantic-pull-request. Using a pure-shell regex check keeps the workflow self-contained and removes the third-party dependency, which also reduces supply-chain risk.
1 parent 84ebd36 commit 9f95e79

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

.github/workflows/lint-pr.yaml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,35 @@ jobs:
1414
validate-pr-title:
1515
name: Validate PR title (Conventional Commits)
1616
runs-on: ubuntu-latest
17-
permissions:
18-
statuses: write
19-
pull-requests: read
17+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-conventional-commit-check') }}
2018
steps:
21-
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
19+
- name: Check Conventional Commits format
2220
env:
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
with:
25-
types: |
26-
feat
27-
fix
28-
docs
29-
style
30-
refactor
31-
test
32-
chore
33-
ci
34-
build
35-
perf
36-
revert
37-
requireScope: false
38-
# Allow skipping this check with a label (e.g. for automated/bot PRs)
39-
ignoreLabels: |
40-
skip-conventional-commit-check
21+
PR_TITLE: ${{ github.event.pull_request.title }}
22+
run: |
23+
# Conventional Commits: <type>(<optional-scope>)(!): <subject>
24+
# Allowed types match the project's release-please changelog sections.
25+
PATTERN='^(feat|fix|docs|style|refactor|test|chore|ci|build|perf|revert)(\([^)]+\))?!?: .+'
26+
27+
if printf '%s' "$PR_TITLE" | grep -qE "$PATTERN"; then
28+
echo "PR title is a valid Conventional Commit: $PR_TITLE"
29+
exit 0
30+
fi
31+
32+
{
33+
echo "::error title=Invalid PR title::PR title must follow Conventional Commits format."
34+
echo " Got: $PR_TITLE"
35+
echo " Expected: <type>(<optional-scope>)(!): <subject>"
36+
echo " Types: feat, fix, docs, style, refactor, test, chore, ci, build, perf, revert"
37+
echo ""
38+
echo " Examples:"
39+
echo " feat: add new endpoint"
40+
echo " fix(client): handle empty response"
41+
echo " chore!: drop python 3.11 support"
42+
echo ""
43+
echo " Add the 'skip-conventional-commit-check' label to bypass this check."
44+
} >&2
45+
exit 1
4146
4247
validate-pr-base:
4348
name: Validate PR base branch

0 commit comments

Comments
 (0)