diff --git a/.github/commit-check.toml b/.github/commit-check.toml new file mode 100644 index 0000000..33552a8 --- /dev/null +++ b/.github/commit-check.toml @@ -0,0 +1,21 @@ +[commit] +conventional_commits = true +subject_capitalized = false +subject_imperative = false +subject_max_length = 200 +subject_min_length = 1 +allow_commit_types = [ + "fix", + "feat", + "build", + "chore", + "docs", + "style", + "refactor", + "remove", + "deprecate", + "security", + "add", + "perf", + "test", +] diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index f9f3ff6..362ba5f 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -43,6 +43,13 @@ jobs: permissions: contents: read steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + # No path set — checks out to workspace root so commit-check-action + # can auto-discover .github/commit-check.toml. Also provides + # cspell.config.yml as a fallback for consuming repos. + with: + persist-credentials: false + repository: cpp-linter/.github - name: Checkout ${{ github.repository }} repo # needed for cspell.config.yml (project-specific) uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -51,13 +58,11 @@ jobs: repository: ${{ github.repository }} ref: ${{ github.sha }} path: project-repo - - name: Checkout cpp-linter/.github (org) repo - # needed for committed.toml config (org-specific) - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: commit-check/commit-check-action@60e903b3fb06f5e64580b959f58d5b9406a3e002 # v2.9.0 with: - persist-credentials: false - repository: cpp-linter/.github - path: org-repo + message: false + branch: false + pr-title: true - name: Get PR title id: get-title env: @@ -67,18 +72,6 @@ jobs: run: |- pr_title=$(gh pr view "${PR_NUMBER}" --repo "${GH_REPO}" --json "title" -q ".title") echo "title=${pr_title}" >> "${GITHUB_OUTPUT}" - - run: rustup update --no-self-update - - name: Install cargo-binstall - uses: cargo-bins/cargo-binstall@732870f031d2fb36309d0deaf36abcc704a7be65 # v1.20.1 - - name: Install committed - run: cargo binstall -y committed - env: - GITHUB_TOKEN: ${{ github.token }} - - name: conventional-commit - env: - PR_TITLE: "${{ steps.get-title.outputs.title }}" - COMMITTED_CONFIG: ${{ github.workspace }}/org-repo/.github/committed.toml - run: echo "${PR_TITLE}" | committed --config "${COMMITTED_CONFIG}" --commit-file - - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: latest @@ -89,6 +82,6 @@ jobs: if [ -f project-repo/cspell.config.yml ]; then CSPELL_CONFIG="project-repo/cspell.config.yml" else - CSPELL_CONFIG="org-repo/cspell.config.yml" + CSPELL_CONFIG="cspell.config.yml" fi echo "${PR_TITLE}" | npx cspell-cli lint --config "${CSPELL_CONFIG}" stdin