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

Function withReleaseToken

packages/bumpy/src/core/github-release.ts:21–39  ·  view source on GitHub ↗

* Run an async function with BUMPY_GH_TOKEN as GH_TOKEN if available. * * GitHub releases created with the default GITHUB_TOKEN won't trigger * downstream workflows. Using BUMPY_GH_TOKEN (a PAT or App token) * allows `release` events to fire follow-up workflows. * * Any errors are scrubbed so

(fn: () => Promise<T>)

Source from the content-addressed store, hash-verified

19 * Any errors are scrubbed so the token never appears in CI logs.
20 */
21async function withReleaseToken<T>(fn: () => Promise<T>): Promise<T> {
22 const token = process.env.BUMPY_GH_TOKEN;
23 if (!token) return fn();
24 const original = process.env.GH_TOKEN;
25 process.env.GH_TOKEN = token;
26 try {
27 return await fn();
28 } catch (err) {
29 // Redact token from error messages to prevent leakage in CI logs
30 const msg = err instanceof Error ? err.message : String(err);
31 throw new Error(msg.replaceAll(token, '***'));
32 } finally {
33 if (original !== undefined) {
34 process.env.GH_TOKEN = original;
35 } else {
36 delete process.env.GH_TOKEN;
37 }
38 }
39}
40
41export interface GitHubReleaseOptions {
42 dryRun?: boolean;

Callers 5

createIndividualReleasesFunction · 0.85
createDraftReleaseFunction · 0.85
updateReleaseBodyFunction · 0.85
finalizeReleaseFunction · 0.85
deleteReleaseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…