* Push a branch to origin, optionally using a custom GitHub token. * * When `BUMPY_GH_TOKEN` is set, the remote URL is temporarily rewritten to * include the token. Pushes made with a PAT or GitHub App token bypass * GitHub's anti-recursion guard, allowing `pull_request` workflows to fire * on
(rootDir: string, branch: string, config: BumpyConfig)
| 697 | * but PR workflows won't be triggered automatically. |
| 698 | */ |
| 699 | function pushWithToken(rootDir: string, branch: string, config: BumpyConfig): void { |
| 700 | // Guard against misconfigured versionPr.branch pointing at the base branch |
| 701 | if (branch === config.baseBranch || branch === 'main' || branch === 'master') { |
| 702 | throw new Error(`Refusing to force-push to "${branch}" — this looks like a base branch, not a version PR branch`); |
| 703 | } |
| 704 | |
| 705 | withGitToken(rootDir, () => { |
| 706 | // --no-verify skips pre-push hooks (e.g. bumpy check) which would fail |
| 707 | // on the version branch since bump files are consumed during versioning |
| 708 | runArgs(['git', 'push', '-u', 'origin', branch, '--force', '--no-verify'], { cwd: rootDir }); |
| 709 | }); |
| 710 | |
| 711 | if (process.env.BUMPY_GH_TOKEN && process.env.GITHUB_REPOSITORY) { |
| 712 | log.dim(' Pushed with custom token — PR workflows will be triggered'); |
| 713 | } else if (!process.env.BUMPY_GH_TOKEN && process.env.GITHUB_REPOSITORY) { |
| 714 | // Only warn on GitHub Actions — other CI providers don't have this limitation |
| 715 | log.warn( |
| 716 | 'BUMPY_GH_TOKEN is not set — PR checks will not trigger automatically.\n' + ' Run `bumpy ci setup` for help.', |
| 717 | ); |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | // ---- version-pr mode ---- |
| 722 |
no test coverage detected
searching dependent graphs…