1
+ # ? should we comment in the PR?
1
2
name : Enforce Semantic Commits
2
3
3
4
on :
@@ -10,41 +11,64 @@ jobs:
10
11
runs-on : ubuntu-latest
11
12
12
13
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
14
+ - name : git clone
15
+ uses : actions/checkout@v4
16
+ - name : Setup
17
+ uses : ./.github/actions/setup
18
18
19
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
20
+ run : npx commitlint --from=origin/${{ github.base_ref }}
23
21
24
- # 'Check if the PR title is a valid semantic commit message'
25
- check-pr-title :
26
- name : Check PR Title
22
+ # Based on PR name
23
+ generate-commit-message :
24
+ name : Generate Commit Message
27
25
runs-on : ubuntu-latest
26
+ outputs :
27
+ commit_message : ${{ steps.generate-message.outputs.commit_message }}
28
28
steps :
29
- - uses : actions/checkout@v4
30
- - uses : ./.github/ actions/setup
29
+ - name : git clone
30
+ uses : actions/checkout@v4
31
31
32
- - name : Check PR Title
32
+ - name : Generate Title
33
+ id : generate-message
33
34
run : |
34
- PR_TITLE='${{ github.event.pull_request.title }}'
35
- echo "PR TITLE": '$PR_TITLE'
36
- echo "$PR_TITLE" | npx commitlint
35
+ COMMIT_MESSAGE='${{ github.event.pull_request.title }}'
36
+ echo "Commit Message": '$COMMIT_MESSAGE'
37
+ echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
38
+ echo "$COMMIT_MESSAGE"
37
39
38
- generate-changelog :
39
- name : Generate Changelog # ? should we comment in the PR?
40
+ validate-commit-message :
41
+ needs : [generate-commit-message]
42
+ name : Validate Commit Message
40
43
runs-on : ubuntu-latest
41
44
steps :
42
- - uses : actions/checkout@v4
45
+ - name : git clone
46
+ uses : actions/checkout@v4
47
+ - name : Setup
48
+ uses : ./.github/actions/setup
43
49
with :
44
- fetch-depth : 0
45
- - uses : ./.github/actions/setup
50
+ full-checkout : false
51
+
52
+ - name : Validate Title
53
+ run : echo "${{needs.generate-commit-message.outputs.commit_message}}" | npx commitlint
54
+
55
+ generate-changelog :
56
+ needs : [generate-commit-message, validate-commit-message]
57
+ name : Generate Changelog
58
+ runs-on : ubuntu-latest
59
+ steps :
60
+ - name : git clone
61
+ uses : actions/checkout@v4
62
+ - name : Setup
63
+ uses : ./.github/actions/setup
64
+
65
+ - name : Generate tmp branch
66
+ run : git checkout -b changelog
46
67
47
- - name : Generate Changelog
68
+ - name : Squash commits
48
69
run : |
49
- git checkout -b changelog
50
- npx nx version ngx-deploy-npm --dry-run
70
+ git reset --soft $(git merge-base origin/${{ github.base_ref }} HEAD)
71
+ git commit -m "$COMMIT_MESSAGE"
72
+ git log -n 3
73
+ env :
74
+ COMMIT_MESSAGE : ${{needs.generate-commit-message.outputs.commit_message}}
0 commit comments