Skip to content

Commit a3955f2

Browse files
authored
fix(gha-onboarding): don't run git commands in CI (#657)
* fix(gha-onboarding): don't run git commands in CI * test: add test assertion for this case
1 parent 0007322 commit a3955f2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

__tests__/lib/createGHA.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ describe('#createGHA', () => {
177177
it('should not run if in a CI environment', async () => {
178178
process.env.TEST_CI = 'true';
179179
await expect(createGHA('success!', cmd, command.args, opts)).resolves.toBe('success!');
180+
// asserts that git commands aren't run in CI
181+
expect(git.checkIsRepo).not.toHaveBeenCalled();
180182
delete process.env.TEST_CI;
181183
});
182184

src/lib/createGHA/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ export default async function createGHA(
165165
debug(`running GHA onboarding for ${command} command`);
166166
debug(`opts used in createGHA: ${JSON.stringify(opts)}`);
167167

168+
// if in a CI environment,
169+
// don't even bother running the git commands
170+
if (!opts.github && isCI()) {
171+
return msg;
172+
}
173+
168174
const { containsGitHubRemote, containsNonGitHubRemote, defaultBranch, isRepo, repoRoot } = await getGitData();
169175

170176
const configVal = configstore.get(getConfigStoreKey(repoRoot));
@@ -177,8 +183,6 @@ export default async function createGHA(
177183
if (
178184
// not a repo
179185
!isRepo ||
180-
// in a CI environment
181-
isCI() ||
182186
// user has previously declined to set up GHA for current repo and `rdme` package version
183187
configVal === majorPkgVersion ||
184188
// is a repo, but only contains non-GitHub remotes

0 commit comments

Comments
 (0)