Skip to content

Commit 43af65e

Browse files
committed
ci: squash pr commits
1 parent a7a96e1 commit 43af65e

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
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:

.github/workflows/enforce-semantic-commits.yml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,55 @@ jobs:
2121
COMMIT_MESSAGES="$(git log --pretty=format:'%s' --abbrev-commit ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})"
2222
echo "$COMMIT_MESSAGES" | npx commitlint
2323
24-
# 'Check if the PR title is a valid semantic commit message'
25-
check-pr-title:
26-
name: Check PR Title
24+
# Based on PR name
25+
generate-commit-message:
26+
name: Generate Commit Message
2727
runs-on: ubuntu-latest
28+
outputs:
29+
commit_message: ${{ steps.generate-message.outputs.commit_message }}
2830
steps:
2931
- uses: actions/checkout@v4
30-
- uses: ./.github/actions/setup
3132

32-
- name: Check PR Title
33+
- name: Generate Title
34+
id: generate-message
3335
run: |
34-
PR_TITLE='${{ github.event.pull_request.title }}'
35-
echo "PR TITLE": '$PR_TITLE'
36-
echo "$PR_TITLE" | npx commitlint
36+
COMMIT_MESSAGE='${{ github.event.pull_request.title }}'
37+
echo "Commit Message": '$COMMIT_MESSAGE'
38+
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
39+
40+
validate-commit-message:
41+
needs: [generate-commit-message]
42+
name: Generate Commit Message
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: ./.github/actions/setup
47+
with:
48+
full-checkout: false
49+
50+
- name: Validate Title
51+
run: echo "${{needs.generate-commit-message.outputs.commit_message}}" | npx commitlint
3752

3853
generate-changelog:
54+
needs: [generate-commit-message, validate-commit-message]
3955
name: Generate Changelog #? should we comment in the PR?
4056
runs-on: ubuntu-latest
4157
steps:
4258
- uses: actions/checkout@v4
43-
with:
44-
fetch-depth: 0
4559
- uses: ./.github/actions/setup
4660

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