1+ # ? should we comment in the PR?
12name : Enforce Semantic Commits
23
34on :
@@ -10,41 +11,64 @@ jobs:
1011 runs-on : ubuntu-latest
1112
1213 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
1818
1919 - 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 }}
2321
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
2725 runs-on : ubuntu-latest
26+ outputs :
27+ commit_message : ${{ steps.generate-message.outputs.commit_message }}
2828 steps :
29- - uses : actions/checkout@v4
30- - uses : ./.github/ actions/setup
29+ - name : git clone
30+ uses : actions/checkout@v4
3131
32- - name : Check PR Title
32+ - name : Generate Title
33+ id : generate-message
3334 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"
3739
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
4043 runs-on : ubuntu-latest
4144 steps :
42- - uses : actions/checkout@v4
45+ - name : git clone
46+ uses : actions/checkout@v4
47+ - name : Setup
48+ uses : ./.github/actions/setup
4349 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
4667
47- - name : Generate Changelog
68+ - name : Squash commits
4869 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
73+ env :
74+ COMMIT_MESSAGE : ${{needs.generate-commit-message.outputs.commit_message}}
0 commit comments