-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set default user.name and user.email #584
base: main
Are you sure you want to change the base?
Conversation
+1 for using |
Co-authored-by: Usman <[email protected]>
await git.config('user.name', github.context.workflow, true) | ||
} | ||
if (!await git.configExists('user.email', true)) { | ||
await git.config('user.email', '[email protected]', true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a bot account for GitHub Actions. It seems like it's a decent default.
Lines 283 to 284 in 692973e
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
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 |
This PR sets up a default
user.name
anduser.email
for 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 --global
afteractions/checkout
they'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 commit
is documented in the README.md. The relevant text of ADR 0153 reads:Default user.name
I used
$GITHUB_WORKFLOW
for the defaultuser.name
because 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_WORKFLOW
looks 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 ("[email protected]"), however @JojOatXGME lays out the options.