diff --git a/commitlint.config.js b/.commitlintrc.json similarity index 86% rename from commitlint.config.js rename to .commitlintrc.json index 44d85ad..311c351 100644 --- a/commitlint.config.js +++ b/.commitlintrc.json @@ -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"], @@ -8,7 +8,7 @@ module.exports = { "scope-case": [2, "always", "lower-case"], "scope-empty": [1, "never"], "scope-enum": [ - 1, + 2, "always", [ "checks", @@ -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", "."], @@ -46,8 +45,8 @@ module.exports = { "refactor", "revert", "style", - "test", - ], - ], - }, -}; + "test" + ] + ] + } +} diff --git a/.github/workflows/pr-title.yaml b/.github/workflows/pr-title.yaml index eb6649d..a8caf2f 100644 --- a/.github/workflows/pr-title.yaml +++ b/.github/workflows/pr-title.yaml @@ -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<> "$GITHUB_ENV" + - name: Validate PR title conforms to conventional spec id: validate-pr-title env: @@ -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