mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-21 09:10:16 +03:00
feat(git config): Set default user.name and user.email in git config
This commit is contained in:
parent
cbb722410c
commit
f3b199b7ed
6 changed files with 26 additions and 4 deletions
|
@ -274,6 +274,14 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
settings.commit,
|
||||
settings.githubServerUrl
|
||||
)
|
||||
if (settings.configureUser) {
|
||||
if (!await git.configExists('user.name', true)) {
|
||||
await git.config('user.name', 'github-action[bot]', true)
|
||||
}
|
||||
if (!await git.configExists('user.email', true)) {
|
||||
await git.config('user.email', '41898282+github-actions[bot]@users.noreply.github.com', true)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// Remove auth
|
||||
if (authHelper) {
|
||||
|
|
|
@ -79,6 +79,11 @@ export interface IGitSourceSettings {
|
|||
*/
|
||||
authToken: string
|
||||
|
||||
/**
|
||||
* Indicates whether to set a default user name and email in the local git config
|
||||
*/
|
||||
configureUser: boolean
|
||||
|
||||
/**
|
||||
* The SSH key to configure
|
||||
*/
|
||||
|
|
|
@ -138,6 +138,10 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
// Auth token
|
||||
result.authToken = core.getInput('token', {required: true})
|
||||
|
||||
// Configure user
|
||||
result.configureUser =
|
||||
(core.getInput('configure-user') || 'true').toUpperCase() === 'TRUE'
|
||||
|
||||
// SSH
|
||||
result.sshKey = core.getInput('ssh-key')
|
||||
result.sshKnownHosts = core.getInput('ssh-known-hosts')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue