Skip to content

Commit 29a5ebb

Browse files
committed
feat: add auto-fix-git-user and auto-fix-git-email inputs
Add configurable git identity for auto-fix commits to address 2bndy5's concern about commit author reflecting the token owner. - auto-fix-git-user: custom git username for the auto-fix commit (defaults to GITHUB_ACTOR) - auto-fix-git-email: custom git email for the auto-fix commit (defaults to GITHUB_ACTOR_ID+GITHUB_ACTOR@users.noreply.github.com) - When empty, falls back to GITHUB_ACTOR/GITHUB_ACTOR_ID based values
1 parent 27afda0 commit 29a5ebb

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

action.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,20 @@ inputs:
227227
Only used when ``auto-fix`` is ``true``.
228228
default: 'style: apply styling format fix'
229229
required: false
230+
auto-fix-git-user:
231+
description: |-
232+
Git username for the auto-fix commit.
233+
Defaults to ``$GITHUB_ACTOR`` (the user who triggered the workflow).
234+
Only used when ``auto-fix`` is ``true``.
235+
default: ''
236+
required: false
237+
auto-fix-git-email:
238+
description: |-
239+
Git email for the auto-fix commit.
240+
Defaults to ``$GITHUB_ACTOR_ID+$GITHUB_ACTOR@users.noreply.github.com``.
241+
Only used when ``auto-fix`` is ``true``.
242+
default: ''
243+
required: false
230244
jobs:
231245
description: |
232246
The number of jobs to run in parallel.
@@ -526,8 +540,18 @@ runs:
526540
if $has_changes {
527541
let actor_name = $env.GITHUB_ACTOR
528542
let actor_id = $env.GITHUB_ACTOR_ID
529-
let git_user = $"user.name=($actor_name)"
530-
let git_email = $"user.email=($actor_id)+($actor_name)@users.noreply.github.com"
543+
let git_user_name = if ('${{ inputs.auto-fix-git-user }}' | is-empty) {
544+
$actor_name
545+
} else {
546+
'${{ inputs.auto-fix-git-user }}'
547+
}
548+
let git_user_email = if ('${{ inputs.auto-fix-git-email }}' | is-empty) {
549+
$"($actor_id)+($actor_name)@users.noreply.github.com"
550+
} else {
551+
'${{ inputs.auto-fix-git-email }}'
552+
}
553+
let git_user = $"user.name=($git_user_name)"
554+
let git_email = $"user.email=($git_user_email)"
531555
^git add -A
532556
let commit_msg = if ('${{ inputs.auto-fix-commit-msg }}' | is-empty) {
533557
'style: apply styling format fix'

docs/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ inputs:
5252
required-permission: 'contents: write #auto-fix'
5353
auto-fix-commit-msg:
5454
minimum-version: '2.19.0'
55+
auto-fix-git-user:
56+
minimum-version: '2.19.0'
57+
auto-fix-git-email:
58+
minimum-version: '2.19.0'
5559
jobs:
5660
minimum-version: '2.11.0'
5761
cache-enable:

0 commit comments

Comments
 (0)