Skip to content

Commit 05361d4

Browse files
authored
chore: semantic pr title workflow (#2779)
* chore: remove card workflow since this workflow was written GitHub projects has built in some of its functionality * chore: commitlint validator workflow * chore: prlint version * chore: prlint deps * chore: semantic title lint * chore: workflow
1 parent 75ae7e1 commit 05361d4

File tree

8 files changed

+69
-348
lines changed

8 files changed

+69
-348
lines changed

.commitlintrc.cjs

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

.github/workflows/commitlint.yml

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,68 @@ on:
66
types:
77
- opened
88
- edited
9-
- labeled
10-
- auto_merge_enabled
119
- synchronize
1210
- reopened
13-
- ready_for_review
11+
pull_request_target:
12+
types:
13+
- opened
14+
- edited
15+
- synchronize
16+
- reopened
1417

1518
pull_request_review:
1619
types:
1720
- submitted
1821

19-
env:
20-
TOKEN: "${{ secrets.GITHUB_TOKEN }}"
22+
permissions:
23+
pull-requests: read
2124

2225
# Separate jobs can run concurrently
2326
jobs:
2427
prTitle:
2528
name: Validate conventional commit format for title
2629
runs-on: ubuntu-latest
30+
permissions:
31+
pull-requests: write
32+
contents: read
2733

2834
steps:
29-
- uses: actions/checkout@v3
35+
- uses: actions/checkout@v4
3036
with:
3137
fetch-depth: 0
32-
33-
# https://github.com/wagoid/commitlint-github-action/issues/560#issuecomment-1277659864
34-
- run: rm tsconfig.json
35-
36-
- uses: wagoid/commitlint-github-action@v5
37-
id: commitlint
38-
continue-on-error: true
38+
- uses: actions/setup-node@v4
3939
with:
40-
configFile: .commitlintrc.cjs
40+
node-version: 20
41+
cache: npm
42+
- run: npm ci --prefer-offline
43+
- run: npm i @commitlint/load
4144

42-
- name: Validate conventional commit format for title
43-
id: prTitle
44-
if: ${{ steps.commitlint.outcome == 'failure' }}
45-
uses: aslafy-z/[email protected]
46-
continue-on-error: true
47-
with:
48-
success-state: Title follows the conventional commit format.
49-
failure-state: Please update the title to use conventional commit format.
50-
context-name: conventional-pr-title
51-
preset: '@commitlint/config-conventional@latest'
52-
env:
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
- id: prlint
46+
uses: kevintyj/prlint@v2
5447

55-
- name: Format commitlint messages
56-
id: format
57-
if: ${{ steps.commitlint.outcome == 'failure' }}
58-
uses: actions/github-script@v6
59-
with:
60-
github-token: ${{ secrets.GITHUB_TOKEN }}
61-
script: |
62-
const results = ${{ steps.commitlint.outputs.results }};
63-
const titleGood = ${{ steps.prTitle.outputs.success }};
64-
const { format } = await import('${{ github.workspace }}/scripts/format-commitlint-messages.js');
65-
return format({ core, results, titleGood });
66-
67-
- name: Notify PR
68-
if: ${{ steps.commitlint.outcome == 'failure' && steps.prTitle.outputs.success == 'false' }}
69-
id: comment
48+
- id: comment
7049
uses: marocchino/sticky-pull-request-comment@v2
7150
with:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7351
header: commitlint
7452
message: |
75-
${{ steps.format.outputs.result }}
53+
## ${{ steps.prlint.outputs.lint-status }}
54+
55+
<details><summary>More Info</summary>
7656
77-
- name: Fail Job on Error
78-
if: ${{ steps.commitlint.outcome == 'failure' && steps.prTitle.outputs.success == 'false' }}
79-
uses: actions/github-script@v6
57+
```json
58+
${{ toJSON(fromJSON(steps.prlint.outputs.lint-details)) }}
59+
```
60+
61+
</details>
62+
63+
- uses: actions/github-script@v7
64+
env:
65+
PR_TITLE_VALID: ${{ fromJSON(steps.prlint.outputs.lint-details).valid }}
66+
PR_LINT_STATUS: ${{ steps.prlint.outputs.lint-status }}
8067
with:
8168
script: |
82-
core.setFailed("There were problems with this PR's commit messages")
69+
const { PR_LINT_STATUS, PR_TITLE_VALID } = process.env;
70+
71+
if (PR_TITLE_VALID.toString() !== 'true')
72+
core.setFailed(PR_LINT_STATUS);
8373

.github/workflows/label.yml

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

.github/workflows/merge-label.yml

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

.github/workflows/project.yml

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

.github/workflows/workflow.yml

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

0 commit comments

Comments
 (0)