diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index 06e2e823..2fcc5c56 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -55,7 +55,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(6) + expect(execute).toBeCalledTimes(7) }) it('should catch when a function throws an error', async () => { @@ -102,7 +102,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(6) + expect(execute).toBeCalledTimes(7) }) it('should not unset git config if a user is using ssh', async () => { @@ -124,7 +124,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(5) + expect(execute).toBeCalledTimes(6) process.env.CI = undefined }) @@ -145,7 +145,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(6) + expect(execute).toBeCalledTimes(7) }) }) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 758e1115..0b29e928 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -53,7 +53,7 @@ describe('main', () => { debug: true }) await run(action) - expect(execute).toBeCalledTimes(16) + expect(execute).toBeCalledTimes(17) expect(rmRF).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1) }) @@ -73,7 +73,7 @@ describe('main', () => { isTest: TestFlag.HAS_CHANGED_FILES }) await run(action) - expect(execute).toBeCalledTimes(19) + expect(execute).toBeCalledTimes(20) expect(rmRF).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1) }) diff --git a/src/git.ts b/src/git.ts index 02207af8..50a9659b 100644 --- a/src/git.ts +++ b/src/git.ts @@ -21,6 +21,16 @@ export async function init(action: ActionInterface): Promise { info(`Deploying using ${action.tokenType}… 🔑`) info('Configuring git…') + try { + await execute( + `git config --global --add safe.directory "${action.workspace}"`, + action.workspace, + action.silent + ) + } catch { + info('Unable to set workspace as a safe directory…') + } + await execute( `git config user.name "${action.name}"`, action.workspace,