Skip to content

Commit 05a6d98

Browse files
[PATCH] Fix merge squash commit message (#14)
* add extra empty commit if needed * fixes * try triggering empty commit * fix action argument `arg` * fix 'not a git repository' error * try fetch-depth=1 * checkout branch directly with the action * correct way was to actually use checkout action * Add empty commit to force PR merge squash using PR title * change author names of automatic commits * use true github bot users * Add empty commit to force PR merge squash using PR title * all good * re-enable security checks Co-authored-by: ValentinFrancois <ValentinFrancois@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 5a7ccd1 commit 05a6d98

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

.github/workflows/check_pr_code.yml

+37
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,40 @@ on:
66
jobs:
77
code_checks:
88
uses: ./.github/workflows/_code_checks.yml
9+
10+
count_commits:
11+
needs: code_checks
12+
runs-on: ubuntu-latest
13+
outputs:
14+
n_commits: ${{ steps.count_commits.outputs.n_commits }}
15+
steps:
16+
- name: checkout current branch
17+
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
21+
- name: count commits from main
22+
id: count_commits
23+
run: |
24+
git fetch
25+
N_COMMITS=$(git rev-list origin/main.. --count)
26+
echo "::set-output name=n_commits::${N_COMMITS}"
27+
28+
add_empty_commit_if_only_one:
29+
needs: count_commits
30+
runs-on: ubuntu-latest
31+
if: ${{ needs.count_commit.outputs.n_commits == '1' }}
32+
steps:
33+
- name: checkout current branch
34+
uses: actions/checkout@v2
35+
with:
36+
repository: ${{ github.event.pull_request.head.repo.full_name }}
37+
ref: ${{ github.event.pull_request.head.ref }}
38+
39+
- uses: EndBug/add-and-commit@v8
40+
with:
41+
default_author: github_actions
42+
message: 'Add empty commit to force use PR title during squash merge'
43+
commit: --allow-empty
44+
add: '.' # working tree should be clean
45+
push: true

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131

3232
- name: Setup Git
3333
run: |
34-
git config user.name "version_bump"
35-
git config user.email 'bipboup@imabot.com'
34+
git config user.name github-actions[bot]
35+
git config user.email github-actions[bot]@users.noreply.github.com
3636
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
3737
git checkout "${GITHUB_REF:11}"
3838

0 commit comments

Comments
 (0)