1+ # ? should we comment in the PR?
12name : Enforce Semantic Commits
23
34on :
@@ -21,30 +22,55 @@ jobs:
2122 COMMIT_MESSAGES="$(git log --pretty=format:'%s' --abbrev-commit ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})"
2223 echo "$COMMIT_MESSAGES" | npx commitlint
2324
24- # 'Check if the PR title is a valid semantic commit message'
25- check-pr-title :
26- name : Check PR Title
25+ # Based on PR name
26+ generate-commit-message :
27+ name : Generate Commit Message
2728 runs-on : ubuntu-latest
29+ outputs :
30+ commit_message : ${{ steps.generate-message.outputs.commit_message }}
2831 steps :
2932 - uses : actions/checkout@v4
30- - uses : ./.github/actions/setup
3133
32- - name : Check PR Title
34+ - name : Generate Title
35+ id : generate-message
3336 run : |
34- PR_TITLE ='${{ github.event.pull_request.title }}'
35- echo "PR TITLE ": '$PR_TITLE '
36- echo "$PR_TITLE" | npx commitlint
37+ COMMIT_MESSAGE ='${{ github.event.pull_request.title }}'
38+ echo "Commit Message ": '$COMMIT_MESSAGE '
39+ echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
3740
38- generate-changelog :
39- name : Generate Changelog # ? should we comment in the PR?
41+ validate-commit-message :
42+ needs : [generate-commit-message]
43+ name : Validate Commit Message
4044 runs-on : ubuntu-latest
4145 steps :
4246 - uses : actions/checkout@v4
47+ - uses : ./.github/actions/setup
4348 with :
44- fetch-depth : 0
49+ full-checkout : false
50+
51+ - name : Validate Title
52+ run : echo "${{needs.generate-commit-message.outputs.commit_message}}" | npx commitlint
53+
54+ generate-changelog :
55+ needs : [generate-commit-message, validate-commit-message]
56+ name : Generate Changelog
57+ runs-on : ubuntu-latest
58+ steps :
59+ - uses : actions/checkout@v4
4560 - uses : ./.github/actions/setup
4661
47- - name : Generate Changelog
62+ - name : Generate tmp branch
63+ run : git checkout -b changelog
64+
65+ - run : echo "$COMMIT_MESSAGE"
66+ env :
67+ COMMIT_MESSAGE : ${{needs.generate-commit-message.outputs.commit_message}}
68+
69+ - name : Squash commits
4870 run : |
49- git checkout -b changelog
50- npx nx version ngx-deploy-npm --dry-run
71+ git fetch
72+ git reset --soft $(git merge-base origin/main HEAD)
73+ git commit -m "$COMMIT_MESSAGE"
74+ git log
75+ env :
76+ COMMIT_MESSAGE : ${{needs.generate-commit-message.outputs.commit_message}}
0 commit comments