MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / storeSecret

Function storeSecret

packages/bumpy/src/commands/ci-setup.ts:179–220  ·  view source on GitHub ↗
(rootDir: string, repo: string, token: string, pm: PackageManager)

Source from the content-addressed store, hash-verified

177// ---- Shared helpers ----
178
179async function storeSecret(rootDir: string, repo: string, token: string, pm: PackageManager): Promise<void> {
180 const hasGh = tryRunArgs(['gh', '--version']);
181 if (!hasGh) {
182 p.log.warn("`gh` CLI not found — you'll need to add the secret manually.");
183 p.note(
184 `Go to: https://github.com/${repo}/settings/secrets/actions/new\n` +
185 `Name: ${pc.bold('BUMPY_GH_TOKEN')}\nValue: (the token you just created)`,
186 'Add repository secret manually',
187 );
188 printPatWorkflowSnippet(pm);
189 p.outro(pc.green('Setup complete!'));
190 return;
191 }
192
193 // Check if the secret already exists
194 const existingSecrets = tryRunArgs(['gh', 'secret', 'list', '--repo', repo], { cwd: rootDir });
195 const isReplacing = existingSecrets?.includes('BUMPY_GH_TOKEN') ?? false;
196
197 const spin = p.spinner();
198 spin.start(
199 isReplacing ? 'Replacing BUMPY_GH_TOKEN repository secret...' : 'Storing BUMPY_GH_TOKEN as a repository secret...',
200 );
201 try {
202 // gh secret set reads from stdin and overwrites if the secret already exists
203 tryRunArgs(['gh', 'secret', 'set', 'BUMPY_GH_TOKEN', '--repo', repo], {
204 cwd: rootDir,
205 input: token,
206 } as any);
207 spin.stop(isReplacing ? 'Secret replaced!' : 'Secret stored!');
208 } catch {
209 spin.stop('Failed to store secret');
210 p.log.warn('Could not store the secret automatically.');
211 p.note(
212 `Go to: https://github.com/${repo}/settings/secrets/actions/new\n` +
213 `Name: ${pc.bold('BUMPY_GH_TOKEN')}\nValue: (the token you just created)`,
214 'Add repository secret manually',
215 );
216 }
217
218 printPatWorkflowSnippet(pm);
219 p.outro(pc.green('Setup complete!'));
220}
221
222function printPatWorkflowSnippet(pm: PackageManager): void {
223 const runCmd = pmxCommand(pm);

Callers 1

setupPatFunction · 0.85

Calls 2

tryRunArgsFunction · 0.90
printPatWorkflowSnippetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…