Skip to content

Commit

Permalink
feat(pr-title): Add commitlint scopes (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris3ware authored Feb 26, 2025
1 parent 970f2d6 commit 827f302
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
21 changes: 10 additions & 11 deletions commitlint.config.js → .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
rules: {
{
"rules": {
"body-leading-blank": [1, "always"],
"body-max-line-length": [2, "always", 72],
"footer-leading-blank": [1, "always"],
Expand All @@ -8,7 +8,7 @@ module.exports = {
"scope-case": [2, "always", "lower-case"],
"scope-empty": [1, "never"],
"scope-enum": [
1,
2,
"always",
[
"checks",
Expand All @@ -23,10 +23,9 @@ module.exports = {
"terraform-dir",
"terraform-docs",
"trunk",
"workflows",
],
"workflows"
]
],
//"signed-off-by": [1, "always", "Signed-off-by:"],
"subject-case": [1, "always", "sentence-case"],
"subject-empty": [2, "never"],
"subject-full-stop": [2, "never", "."],
Expand All @@ -46,8 +45,8 @@ module.exports = {
"refactor",
"revert",
"style",
"test",
],
],
},
};
"test"
]
]
}
}
20 changes: 15 additions & 5 deletions .github/workflows/pr-title.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,23 @@ jobs:
# Run if PR title length job does not exit
needs: [pr-title-length]
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- name: Get commitlint scopes from configuration file
id: commit_scope
run: |
{
echo 'COMMIT_SCOPES<<EOF'
jq -r '.rules["scope-enum"][2][]' .commitlintrc.json
echo EOF
} >> "$GITHUB_ENV"
- name: Validate PR title conforms to conventional spec
id: validate-pr-title
env:
Expand All @@ -75,11 +88,8 @@ jobs:
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
with:
requireScope: true
# TODO: Required scopes for this repo and as an input when called
# TODO: Add scopes to PR comment if applicable
# scopes: Ideally get them from the commitlint config file to avoid duplication
# Maybe use this action; will require commitlint.config.js changing to .commitlintrc.json
# https://github.com/marketplace/actions/get-properties-from-json-file
scopes: |
${{ env.COMMIT_SCOPES }}
subjectPattern: ^([A-Z]).+$ # Subject must start with an upper case character
subjectPatternError: |
The subject "{subject}" found in the pull request title
Expand Down

0 comments on commit 827f302

Please sign in to comment.