Skip to content

Commit 0c2387c

Browse files
Copilotpetesramek
andauthored
refactor: extract git identity config into a reusable composite action
Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/c4363748-3a51-4b83-9c29-575de1199116 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent 8787245 commit 0c2387c

6 files changed

Lines changed: 23 additions & 14 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: 'Configure git identity'
2+
author: 'Pete Sramek'
3+
description: 'Configures git user name and email from the last commit.'
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: 'Configure git identity'
9+
shell: bash
10+
run: |
11+
git config user.name "$(git log -n 1 --pretty=format:%an)"
12+
git config user.email "$(git log -n 1 --pretty=format:%ae)"

.github/actions/git/push-changes/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ runs:
8787
set -e
8888
working-directory: ${{ inputs.working-directory }}
8989

90+
- name: Configure git identity
91+
if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }}
92+
uses: './.github/actions/git/configure-identity'
93+
9094
- name: Push changes to ${{ github.head_ref || github.ref }}
9195
if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }}
9296
shell: bash
9397
run: |
94-
git config user.name "$(git log -n 1 --pretty=format:%an)"
95-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
9698
git commit -m '${{ inputs.commit-message }}'
9799
git pull --rebase origin ${{ github.head_ref || github.ref }}
98100
git push

.github/actions/github/create-release/action.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ runs:
2626
echo "notes-start-tag-argument=${{ inputs.notes-start-tag != '' && format('--notes-start-tag {0}', inputs.notes-start-tag) || '' }}"
2727
shell: bash
2828
- name: 'Configure git identity'
29-
shell: bash
30-
run: |
31-
git config user.name "$(git log -n 1 --pretty=format:%an)"
32-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
29+
uses: './.github/actions/git/configure-identity'
3330
- name: 'Create git tag ${{ inputs.release-version }}'
3431
shell: bash
3532
run: |

.github/workflows/backtrack.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ jobs:
3030
token: ${{ secrets.GH_ADMIN_TOKEN }}
3131

3232
- name: 'Configure git'
33-
run: |
34-
git config user.name "$(git log -n 1 --pretty=format:%an)"
35-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
33+
uses: './.github/actions/git/configure-identity'
3634

3735
- name: 'Resolve backtrack targets'
3836
id: targets

.github/workflows/bump-version.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ jobs:
113113
dotnet-version: ${{ env.dotnet-sdk-version }}
114114

115115
- name: 'Configure git'
116-
run: |
117-
git config user.name "$(git log -n 1 --pretty=format:%an)"
118-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
116+
uses: './.github/actions/git/configure-identity'
119117

120118
- name: 'Create develop branch from main'
121119
run: |

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,13 @@ jobs:
358358
echo "support-branch-exists=false" >> $GITHUB_OUTPUT
359359
fi
360360
361+
- name: 'Configure git identity'
362+
if: ${{ steps.check-support-branch.outputs.support-branch-exists == 'false' }}
363+
uses: './.github/actions/git/configure-identity'
364+
361365
- name: 'Create support branch'
362366
if: ${{ steps.check-support-branch.outputs.support-branch-exists == 'false' }}
363367
run: |
364-
git config user.name "$(git log -n 1 --pretty=format:%an)"
365-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
366368
git checkout -b "${{ steps.resolve-support-branch.outputs.support-branch }}"
367369
git push --set-upstream origin "${{ steps.resolve-support-branch.outputs.support-branch }}"
368370

0 commit comments

Comments
 (0)