Skip to content

Commit 88a9dc5

Browse files
theoephraimclaude
andcommitted
Detect existing secret and adjust messaging when replacing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 08916b6 commit 88a9dc5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/bumpy/src/commands/ci-setup.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,21 @@ async function storeSecret(rootDir: string, repo: string, token: string, pm: Pac
183183
return;
184184
}
185185

186+
// Check if the secret already exists
187+
const existingSecrets = tryRunArgs(['gh', 'secret', 'list', '--repo', repo], { cwd: rootDir });
188+
const isReplacing = existingSecrets?.includes('BUMPY_GH_TOKEN') ?? false;
189+
186190
const spin = p.spinner();
187-
spin.start('Storing BUMPY_GH_TOKEN as a repository secret...');
191+
spin.start(
192+
isReplacing ? 'Replacing BUMPY_GH_TOKEN repository secret...' : 'Storing BUMPY_GH_TOKEN as a repository secret...',
193+
);
188194
try {
189-
// gh secret set reads from stdin
195+
// gh secret set reads from stdin and overwrites if the secret already exists
190196
tryRunArgs(['gh', 'secret', 'set', 'BUMPY_GH_TOKEN', '--repo', repo], {
191197
cwd: rootDir,
192198
input: token,
193199
} as any);
194-
spin.stop('Secret stored!');
200+
spin.stop(isReplacing ? 'Secret replaced!' : 'Secret stored!');
195201
} catch {
196202
spin.stop('Failed to store secret');
197203
p.log.warn('Could not store the secret automatically.');

0 commit comments

Comments
 (0)