Skip to content

Commit 08a8240

Browse files
committed
ci: create a pr title and commit linter
1 parent 95c5a50 commit 08a8240

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed

.github/workflows/pr.yml renamed to .github/workflows/ci.yml

+4-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: PR's
2-
on:
3-
pull_request:
4-
types: [opened, synchronize, reopened]
1+
name: CI
2+
# on:
3+
# pull_request:
4+
# types: [opened, synchronize, reopened]
55

66
env:
77
PR_NUMBER: ${{ github.event.pull_request.number }}
@@ -13,39 +13,6 @@ jobs:
1313
pr-e2e-test:
1414
uses: ./.github/workflows/e2e-test.yml
1515

16-
check-commit-lint:
17-
name: Check commit message follows guidelines
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: actions/checkout@v4
21-
- uses: ./.github/actions/setup
22-
23-
- name: Execute commitlint
24-
run: npx commitlint --from=origin/${{ github.base_ref }}
25-
26-
- name: Get PR Title
27-
run: "echo 'PR Title: ${{ github.event.pull_request.title }}'"
28-
29-
- name: Get commit messages
30-
run: |
31-
BODY=$(git log \
32-
--abbrev-commit ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \
33-
--pretty=format:'* %s%n%n%b')
34-
TITLE='${{ github.event.pull_request.title }}'
35-
36-
echo $TITLE
37-
echo '---------'
38-
echo $BODY
39-
echo '---------'
40-
echo "${TITLE}\n${BODY}"
41-
echo '---------'
42-
43-
echo "${TITLE}\n${BODY}" > commit-message.txt
44-
cat commit-message.txt
45-
46-
- name: Check commit message
47-
run: cat commit-message.txt | npx commitlint
48-
4916
check-file-format:
5017
name: Check files changes follow guidelines
5118
runs-on: ubuntu-latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Enforce Semantic Commits
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize] #? reopened
6+
7+
jobs:
8+
check-semantic-commits:
9+
name: Check Semantic Commits
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: ./.github/actions/setup
15+
16+
- name: Fetch all commits for the PR
17+
run: git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge
18+
19+
- name: Check commit messages
20+
run: |
21+
COMMIT_MESSAGES="$(git log --pretty=format:'%s' --abbrev-commit ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})"
22+
echo "$COMMIT_MESSAGES" | npx commitlint
23+
24+
# 'Check if the PR title is a valid semantic commit message'
25+
check-pr-title:
26+
name: Check PR Title
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: ./.github/actions/setup
31+
32+
- name: Check PR Title
33+
run: |
34+
PR_TITLE='${{ github.event.pull_request.title }}'
35+
echo "PR TITLE": '$PR_TITLE'
36+
echo "$PR_TITLE" | npx commitlint

0 commit comments

Comments
 (0)