forked from angular-schule/ngx-deploy-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 15
75 lines (62 loc) · 2.25 KB
/
enforce-semantic-commits.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Enforce Semantic Commits
on:
pull_request:
types: [opened, edited, synchronize] #? reopened
jobs:
check-semantic-commits:
name: Check Semantic Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Fetch all commits for the PR
run: git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge
- name: Check commit messages
run: |
COMMIT_MESSAGES="$(git log --pretty=format:'%s' --abbrev-commit ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})"
echo "$COMMIT_MESSAGES" | npx commitlint
# Based on PR name
generate-commit-message:
name: Generate Commit Message
runs-on: ubuntu-latest
outputs:
commit_message: ${{ steps.generate-message.outputs.commit_message }}
steps:
- uses: actions/checkout@v4
- name: Generate Title
id: generate-message
run: |
COMMIT_MESSAGE='${{ github.event.pull_request.title }}'
echo "Commit Message": '$COMMIT_MESSAGE'
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
validate-commit-message:
needs: [generate-commit-message]
name: Generate Commit Message
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
full-checkout: false
- name: Validate Title
run: echo "${{needs.generate-commit-message.outputs.commit_message}}" | npx commitlint
generate-changelog:
needs: [generate-commit-message, validate-commit-message]
name: Generate Changelog #? should we comment in the PR?
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Generate tmp branch
run: git checkout -b changelog
- run: echo "$COMMIT_MESSAGE"
env:
COMMIT_MESSAGE: ${{needs.generate-commit-message.outputs.commit_message}}
- name: Squash commits
run: |
git fetch
git reset --soft $(git merge-base origin/main HEAD)
git commit -m "$COMMIT_MESSAGE"
git log
env:
COMMIT_MESSAGE: ${{needs.generate-commit-message.outputs.commit_message}}