build: validate commit and title message #4
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: Validate PR | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize, reopened] | |
| issue_comment: | |
| types: [created, edited] | |
| jobs: | |
| conventional-commits: | |
| name: Validate PR title | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: amannn/action-semantic-pull-request@v5 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message-validation: | |
| name: Validate commit messages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| - name: Install commitlint | |
| run: npm install -g @commitlint/{cli,config-conventional} | |
| - name: Use default conventional configuration | |
| run: | | |
| echo "module.exports = { extends: ['@commitlint/config-conventional'] }" > $GITHUB_WORKSPACE/commitlint.config.js | |
| - name: Validate current commit (last commit) with commitlint | |
| if: github.event_name == 'push' | |
| run: npx commitlint --from HEAD~1 --to HEAD --verbose | |
| - name: Validate PR commits with commitlint | |
| if: github.event_name == 'pull_request' | |
| run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose |