diff --git a/__tests__/lib/createGHA.test.ts b/__tests__/lib/createGHA.test.ts index 9dfedf574..86e15434d 100644 --- a/__tests__/lib/createGHA.test.ts +++ b/__tests__/lib/createGHA.test.ts @@ -177,6 +177,8 @@ describe('#createGHA', () => { it('should not run if in a CI environment', async () => { process.env.TEST_CI = 'true'; await expect(createGHA('success!', cmd, command.args, opts)).resolves.toBe('success!'); + // asserts that git commands aren't run in CI + expect(git.checkIsRepo).not.toHaveBeenCalled(); delete process.env.TEST_CI; }); diff --git a/src/lib/createGHA/index.ts b/src/lib/createGHA/index.ts index ef922081a..48c850974 100644 --- a/src/lib/createGHA/index.ts +++ b/src/lib/createGHA/index.ts @@ -165,6 +165,12 @@ export default async function createGHA( debug(`running GHA onboarding for ${command} command`); debug(`opts used in createGHA: ${JSON.stringify(opts)}`); + // if in a CI environment, + // don't even bother running the git commands + if (!opts.github && isCI()) { + return msg; + } + const { containsGitHubRemote, containsNonGitHubRemote, defaultBranch, isRepo, repoRoot } = await getGitData(); const configVal = configstore.get(getConfigStoreKey(repoRoot)); @@ -177,8 +183,6 @@ export default async function createGHA( if ( // not a repo !isRepo || - // in a CI environment - isCI() || // user has previously declined to set up GHA for current repo and `rdme` package version configVal === majorPkgVersion || // is a repo, but only contains non-GitHub remotes