Set default user.name and user.email - #584
Open
jablko wants to merge 2 commits into
Open
Conversation
|
+1 for using |
usmonster
reviewed
Oct 5, 2023
Co-authored-by: Usman <akeju00+github@gmail.com>
NatoBoram
reviewed
Jun 13, 2024
Comment on lines
+223
to
+226
| await git.config('user.name', github.context.workflow, true) | ||
| } | ||
| if (!await git.configExists('user.email', true)) { | ||
| await git.config('user.email', 'github-actions@github.com', true) |
There was a problem hiding this comment.
There's already a bot account for GitHub Actions. It seems like it's a decent default.
Lines 283 to 284 in 692973e
Suggested change
| await git.config('user.name', github.context.workflow, true) | |
| } | |
| if (!await git.configExists('user.email', true)) { | |
| await git.config('user.email', 'github-actions@github.com', true) | |
| await git.config('user.name', 'github-actions[bot]', true) | |
| } | |
| if (!await git.configExists('user.email', true)) { | |
| await git.config('user.email', '41898282+github-actions[bot]@users.noreply.github.com', true) |
|
Maybe it make sense to add user as an action input and choose who should be set as user e.g. bot, actor, committer or even manually I've created a handy action for that use case. Feel free to have look at https://github.com/qoomon/actions--setup-git |
farshadjanu1
approved these changes
Feb 5, 2025
2 tasks
2 tasks
This was referenced Jul 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR sets up a default
user.nameanduser.emailfor scriptinggit commit. Users can continue to configure their own values as now, this PR just affords the option not to.Shouldn't affect existing users: If users
git config --global user.{name,email}beforeactions/checkout, this will respect existing values. If theygit config --globalafteractions/checkoutthey'll overwrite these defaults. If theygit config --local(before or after), those values take precedence.Fixes #13, although the issue proposed defaulting to the author/user from the event that triggered the action.
Also discussed in #158, although the PR doesn't propose defaults.
Configuring
user.{name,email}/scriptinggit commitis documented in the README.md. The relevant text of ADR 0153 reads:Default user.name
I used
$GITHUB_WORKFLOWfor the defaultuser.namebecause it's the most helpful value to have in there? Other proposals include the current README.md value ("github-actions") and the author/user from the event that triggered the action.Here's how
$GITHUB_WORKFLOWlooks in GitHub's UI -- however I'm equally happy if a different default is implemented:Default user.email
I went with the current README.md value ("github-actions@github.com"), however @JojOatXGME lays out the options.