Skip to content

Commit 97edc9f

Browse files
committed
ci: squash pr commits
1 parent a7a96e1 commit 97edc9f

File tree

3 files changed

+50
-23
lines changed

3 files changed

+50
-23
lines changed

.github/actions/setup/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ inputs:
44
node-version:
55
description: 'The Node.js version to use. The default one is going to be the defined on the .nvmrc file.'
66
required: false
7+
full-checkout:
8+
description: 'Whether to do a full checkout or not. A full checkout will fetch all commits from the repository.'
9+
required: false
10+
default: true
711
runs:
812
using: composite
913
steps:
1014
- name: Checkout all commits
1115
uses: actions/checkout@v4
1216
with:
13-
fetch-depth: 0
17+
fetch-depth: ${{ inputs.full-checkout == 'true' && 0 || 1 }}
1418

1519
- name: Set Node.js version based on .nvmrc or Action Input
1620
shell: bash
@@ -24,6 +28,12 @@ runs:
2428
echo "NODE_VERSION=${{ inputs.node-version }}" >> $GITHUB_ENV
2529
fi
2630
31+
- name: git config
32+
shell: bash
33+
run: |
34+
git config user.name "ngx-deploy-npm bot"
35+
git config user.email "-"
36+
2737
- name: Use Node.js
2838
uses: actions/setup-node@v4
2939
with:
Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#? should we comment in the PR?
12
name: Enforce Semantic Commits
23

34
on:
@@ -12,39 +13,61 @@ jobs:
1213
steps:
1314
- uses: actions/checkout@v4
1415
- uses: ./.github/actions/setup
16+
with:
17+
full-checkout: false
1518

1619
- name: Fetch all commits for the PR
1720
run: git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge
1821

1922
- name: Check commit messages
23+
run: npx commitlint --from=origin/${{ github.base_ref }}
24+
25+
# Based on PR name
26+
generate-commit-message:
27+
name: Generate Commit Message
28+
runs-on: ubuntu-latest
29+
outputs:
30+
commit_message: ${{ steps.generate-message.outputs.commit_message }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Generate Title
35+
id: generate-message
2036
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
37+
COMMIT_MESSAGE='${{ github.event.pull_request.title }}'
38+
echo "Commit Message": '$COMMIT_MESSAGE'
39+
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
40+
echo "$COMMIT_MESSAGE"
2341
24-
# 'Check if the PR title is a valid semantic commit message'
25-
check-pr-title:
26-
name: Check PR Title
42+
validate-commit-message:
43+
needs: [generate-commit-message]
44+
name: Validate Commit Message
2745
runs-on: ubuntu-latest
2846
steps:
2947
- uses: actions/checkout@v4
3048
- uses: ./.github/actions/setup
49+
with:
50+
full-checkout: false
3151

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
52+
- name: Validate Title
53+
run: echo "${{needs.generate-commit-message.outputs.commit_message}}" | npx commitlint
3754

3855
generate-changelog:
39-
name: Generate Changelog #? should we comment in the PR?
56+
needs: [generate-commit-message, validate-commit-message]
57+
name: Generate Changelog
4058
runs-on: ubuntu-latest
4159
steps:
4260
- uses: actions/checkout@v4
43-
with:
44-
fetch-depth: 0
4561
- uses: ./.github/actions/setup
4662

47-
- name: Generate Changelog
63+
- name: Generate tmp branch
64+
run: git checkout -b changelog
65+
66+
- name: Squash commits
4867
run: |
49-
git checkout -b changelog
50-
npx nx version ngx-deploy-npm --dry-run
68+
git fetch
69+
git reset --soft $(git merge-base origin/main HEAD)
70+
git commit -m "$COMMIT_MESSAGE"
71+
git log
72+
env:
73+
COMMIT_MESSAGE: ${{needs.generate-commit-message.outputs.commit_message}}

.github/workflows/publishment.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ jobs:
5353
- uses: actions/checkout@v4
5454
- uses: ./.github/actions/setup
5555

56-
- name: git config
57-
shell: bash
58-
run: |
59-
git config user.name "Github Actions"
60-
git config user.email "-"
61-
6256
- uses: ./.github/actions/download-build
6357

6458
- name: Check npm credentials

0 commit comments

Comments
 (0)