(rootDir: string, repo: string, pm: PackageManager)
| 117 | // ---- GitHub App flow ---- |
| 118 | |
| 119 | async function setupApp(rootDir: string, repo: string, pm: PackageManager): Promise<void> { |
| 120 | const owner = repo.split('/')[0]!; |
| 121 | const appUrl = `https://github.com/organizations/${owner}/settings/apps/new`; |
| 122 | const personalAppUrl = `https://github.com/settings/apps/new`; |
| 123 | |
| 124 | const isOrg = unwrap(await p.confirm({ message: `Is ${pc.cyan(owner)} a GitHub organization?`, initialValue: true })); |
| 125 | |
| 126 | const createUrl = isOrg ? appUrl : personalAppUrl; |
| 127 | |
| 128 | p.log.info(''); |
| 129 | p.note( |
| 130 | [ |
| 131 | 'If you already have a GitHub App, skip to step 2.', |
| 132 | '', |
| 133 | pc.bold('Step 1: Create a GitHub App'), |
| 134 | '', |
| 135 | `1. Open: ${pc.cyan(createUrl)}`, |
| 136 | `2. Set the name, e.g. ${pc.dim(`"${owner}-bumpy-ci"`)}`, |
| 137 | '3. Uncheck "Active" under Webhooks (not needed)', |
| 138 | '4. Under Permissions → Repository permissions, grant:', |
| 139 | ...PAT_PERMISSIONS.map((perm) => ` • ${pc.bold(perm)}`), |
| 140 | '5. Under "Where can this app be installed?" select "Only on this account"', |
| 141 | '6. Click "Create GitHub App"', |
| 142 | '7. Note the App ID shown on the settings page', |
| 143 | '8. Generate a private key and download the .pem file', |
| 144 | '', |
| 145 | pc.bold('Step 2: Install the App'), |
| 146 | '', |
| 147 | `Install the app on ${pc.cyan(repo)} from the app's "Install App" tab.`, |
| 148 | '', |
| 149 | pc.bold('Step 3: Add secrets'), |
| 150 | '', |
| 151 | "You'll need to add two repository secrets:", |
| 152 | ` • ${pc.bold('BUMPY_APP_ID')} — the App ID`, |
| 153 | ` • ${pc.bold('BUMPY_APP_PRIVATE_KEY')} — contents of the .pem file`, |
| 154 | ].join('\n'), |
| 155 | 'GitHub App setup', |
| 156 | ); |
| 157 | |
| 158 | const shouldOpen = unwrap(await p.confirm({ message: 'Open the app creation page in your browser?' })); |
| 159 | if (shouldOpen) { |
| 160 | openBrowser(createUrl); |
| 161 | } |
| 162 | |
| 163 | const hasSecrets = unwrap( |
| 164 | await p.confirm({ message: 'Have you added the BUMPY_APP_ID and BUMPY_APP_PRIVATE_KEY secrets?' }), |
| 165 | ); |
| 166 | |
| 167 | if (hasSecrets) { |
| 168 | printAppWorkflowSnippet(pm); |
| 169 | } else { |
| 170 | p.log.info('You can add them later. Once ready, update your release workflow:'); |
| 171 | printAppWorkflowSnippet(pm); |
| 172 | } |
| 173 | |
| 174 | p.outro(pc.green('GitHub App setup complete!')); |
| 175 | } |
| 176 |
no test coverage detected
searching dependent graphs…