From d48599a2993b80f59181066b1295533674d04d4d Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Wed, 15 Sep 2021 09:59:02 -0700 Subject: [PATCH 1/2] Set default user.name and user.email --- src/git-source-provider.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 42a12e04e..1da0bfc14 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -1,4 +1,5 @@ import * as core from '@actions/core' +import * as github from '@actions/github' import * as fsHelper from './fs-helper' import * as gitAuthHelper from './git-auth-helper' import * as gitCommandManager from './git-command-manager' @@ -216,6 +217,14 @@ export async function getSource(settings: IGitSourceSettings): Promise { settings.ref, settings.commit ) + + // Set default author + if (!await git.configExists('user.name', true) { + 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) + } } finally { // Remove auth if (!settings.persistCredentials) { From f787e7d544c130d1f240b14444b0ce9724a4f6db Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Fri, 6 Oct 2023 06:25:44 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Usman --- src/git-source-provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 1da0bfc14..18aed12fa 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -219,10 +219,10 @@ export async function getSource(settings: IGitSourceSettings): Promise { ) // Set default author - if (!await git.configExists('user.name', true) { + if (!await git.configExists('user.name', true)) { await git.config('user.name', github.context.workflow, true) } - if (!await git.configExists('user.email', true) { + if (!await git.configExists('user.email', true)) { await git.config('user.email', 'github-actions@github.com', true) } } finally {