Skip to content

Commit 6a36718

Browse files
committed
ci: squash pr commits
1 parent a7a96e1 commit 6a36718

File tree

3 files changed

+60
-32
lines changed

3 files changed

+60
-32
lines changed

.github/actions/setup/action.yml

+11-1
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:
+49-25
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:
@@ -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}}

.github/workflows/publishment.yml

-6
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)