feat(ci): add commitlint workflow and configuration #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint Commit Messages | |
| on: | |
| pull_request: | |
| types: [opened, edited, reopened, synchronize] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| lint-pr-title: | |
| name: Lint PR Title | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install commitlint | |
| run: | | |
| npm install --save-dev @commitlint/[email protected] @commitlint/[email protected] | |
| - name: Validate PR title | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| run: | | |
| echo "Validating PR title: $PR_TITLE" | |
| echo "$PR_TITLE" | npx commitlint --verbose | |
| commitlint: | |
| name: Lint Commit Messages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for all branches and tags | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install commitlint | |
| run: | | |
| npm install --save-dev @commitlint/[email protected] @commitlint/[email protected] | |
| - name: Validate PR commits | |
| run: | | |
| # Get the base branch (usually main) | |
| BASE_SHA=$(git merge-base origin/${{ github.base_ref }} HEAD) | |
| # Lint all commits in the PR | |
| npx commitlint --from $BASE_SHA --to HEAD --verbose |