From 01bcc2efd395c478fe05f1073bf3c233ad600f32 Mon Sep 17 00:00:00 2001 From: Jay Zhang Date: Mon, 30 Sep 2024 02:52:20 +0000 Subject: [PATCH] chore: add pr and commit lint --- .github/configs/commitlint.config.mjs | 3 +++ .github/workflows/commitlint.yml | 16 ++++++++++++++++ .github/workflows/pr_name.yml | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 .github/configs/commitlint.config.mjs create mode 100644 .github/workflows/commitlint.yml create mode 100644 .github/workflows/pr_name.yml diff --git a/.github/configs/commitlint.config.mjs b/.github/configs/commitlint.config.mjs new file mode 100644 index 0000000..0616fb9 --- /dev/null +++ b/.github/configs/commitlint.config.mjs @@ -0,0 +1,3 @@ +export default { + extends: ['@commitlint/config-conventional'], +}; diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 0000000..b0e8947 --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,16 @@ +name: Lint Commit Messages + +on: [pull_request] + +permissions: + contents: read + pull-requests: read + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: wagoid/commitlint-github-action@v6 + with: + configFile: .github/configs/commitlint.config.mjs diff --git a/.github/workflows/pr_name.yml b/.github/workflows/pr_name.yml new file mode 100644 index 0000000..21269ce --- /dev/null +++ b/.github/workflows/pr_name.yml @@ -0,0 +1,22 @@ +name: pr-name-linter + +on: + pull_request: + types: ['opened', 'edited', 'reopened', 'synchronize'] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Dependencies + run: | + npm install @commitlint/config-conventional + echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js + + - name: Lint the PR Title + run: | + echo "${PR_TITLE}" | npx --yes commitlint + env: + PR_TITLE: '${{ github.event.pull_request.title }}'