|
| 1 | +name: Lint PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - edited |
| 8 | + branches: |
| 9 | + - master |
| 10 | + - feature/v3 #TODO: remove |
| 11 | + |
| 12 | +permissions: |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: label-pr-${{ github.event.pull_request.number }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + conventional-pr-title: |
| 21 | + if: github.event.action == 'opened' || github.event.action == 'edited' && github.event.changes.title.from |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Validate PR title |
| 25 | + id: validate-pr-title |
| 26 | + uses: amannn/action-semantic-pull-request@v6 |
| 27 | + continue-on-error: true |
| 28 | + |
| 29 | + - name: Remove PR labels |
| 30 | + if: steps.validate-pr-title.outputs.error_message == null |
| 31 | + run: gh pr edit "$PR_NUMBER" --remove-label "feature,fix,documentation,cicd" |
| 32 | + env: |
| 33 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 35 | + |
| 36 | + - name: Set PR label |
| 37 | + if: steps.validate-pr-title.outputs.error_message == null |
| 38 | + uses: srvaroa/labeler@v1 |
| 39 | + |
| 40 | + - name: Comment on PR title lint error |
| 41 | + if: steps.validate-pr-title.outputs.error_message |
| 42 | + uses: marocchino/sticky-pull-request-comment@v3 |
| 43 | + with: |
| 44 | + header: pr-title-lint-error |
| 45 | + message: | |
| 46 | + 👋 Hey @${{ github.event.pull_request.user.login }}, it looks like the PR title doesn't follow the [Conventional Commits](https://www.conventionalcommits.org) format. |
| 47 | + |
| 48 | + While it's not a blocker for this PR, following the conventional commits format helps us to automatically calculate next release version, categorize changes and generate changelog. |
| 49 | + |
| 50 | + Good candidates might be `feat: ${{ github.event.pull_request.title }}` or `fix: ${{ github.event.pull_request.title }}`. You can also add `!` to indicate a breaking change, e.g. `feat!: ${{ github.event.pull_request.title }}`. |
| 51 | + |
| 52 | + For more details and examples please visit [Conventional Commits](https://www.conventionalcommits.org). 🙌 |
| 53 | +
|
| 54 | + - name: Remove PR title lint error comment |
| 55 | + if: steps.validate-pr-title.outputs.error_message == null |
| 56 | + uses: marocchino/sticky-pull-request-comment@v3 |
| 57 | + with: |
| 58 | + header: pr-title-lint-error |
| 59 | + delete: true |
0 commit comments