|
| 1 | +name: Pull Request Title |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - edited |
| 8 | + - reopened |
| 9 | + - synchronize |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + name: Lint |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + pull-requests: write |
| 21 | + env: |
| 22 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + ERR_MSG: |- |
| 24 | + The PR title `${{ github.event.pull_request.title }}` does not follow the Calimero-Network Commit Message Convention |
| 25 | + https://github.com/calimero-network/core/blob/master/CONTRIBUTING.md#commit-message-style |
| 26 | +
|
| 27 | + Our PR title should have the following structure: |
| 28 | +
|
| 29 | + <type>(<scope>): <subject> |
| 30 | +
|
| 31 | + Common errors to avoid: |
| 32 | + 1. The commit header <type>(<scope>): <subject> must be in lower case. |
| 33 | + 2. Allowed type values are: build, ci, docs, feat, fix, perf, refactor, test. |
| 34 | +
|
| 35 | + The linting rules are defined in: |
| 36 | + https://github.com/calimero-network/core/blob/master/commitlint.config.js |
| 37 | +
|
| 38 | + More about the Commit Message Convention |
| 39 | + https://github.com/calimero-network/core/blob/master/CONTRIBUTING.md#commit-message-style |
| 40 | +
|
| 41 | + steps: |
| 42 | + - uses: amannn/action-semantic-pull-request@v5 |
| 43 | + id: lint_pr_title |
| 44 | + |
| 45 | + - name: Create PR Comment Payload |
| 46 | + if: ${{ !cancelled() }} |
| 47 | + shell: bash |
| 48 | + run: >- |
| 49 | + jq -n |
| 50 | + --arg pr '${{ github.event.number }}' |
| 51 | + --arg tag pr-lint-check |
| 52 | + --arg mode "${{ steps.lint_pr_title.outputs.error_message != null && 'recreate' || 'delete' }}" |
| 53 | + --arg message "${{ env.ERR_MSG }}" |
| 54 | + '{pr: $pr, tag: $tag, mode: $mode, message: $message}' | tee payload.json |
| 55 | +
|
| 56 | + - name: Upload Comment |
| 57 | + if: ${{ !cancelled() }} |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: pr-comment-payload |
| 61 | + path: payload.json |
0 commit comments