Skip to content

Commit cde1120

Browse files
committed
refactor: rename label-pr.yml to conventional-pr-title.yml and update PR title validation workflow
1 parent 1eb438f commit cde1120

4 files changed

Lines changed: 71 additions & 45 deletions

File tree

.github/labeler.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 1
2+
3+
labels:
4+
- label: feature
5+
title: ^feat.*
6+
- label: fix
7+
title: ^fix.*
8+
- label: documentation
9+
title: ^docs.*
10+
- label: cicd
11+
title: ^ci.*

.github/release.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
changelog:
22
categories:
3-
- title: 🚀 Breaking Changes
4-
labels:
5-
- breaking change
63
- title: 🎉 Exciting New Features
74
labels:
85
- feature
@@ -14,7 +11,7 @@ changelog:
1411
- documentation
1512
- title: ⚙️ CI/CD
1613
labels:
17-
- ci/cd
14+
- cicd
1815
- title: ⬆️ Dependencies
1916
labels:
2017
- dependencies
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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

.github/workflows/label-pr.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)