(token: string)
| 986 | } |
| 987 | |
| 988 | async function exchangeForAppToken(token: string) { |
| 989 | const response = token.startsWith("github_pat_") |
| 990 | ? await fetch(`${oidcBaseUrl}/exchange_github_app_token_with_pat`, { |
| 991 | method: "POST", |
| 992 | headers: { |
| 993 | Authorization: `Bearer ${token}`, |
| 994 | }, |
| 995 | body: JSON.stringify({ owner, repo }), |
| 996 | }) |
| 997 | : await fetch(`${oidcBaseUrl}/exchange_github_app_token`, { |
| 998 | method: "POST", |
| 999 | headers: { |
| 1000 | Authorization: `Bearer ${token}`, |
| 1001 | }, |
| 1002 | }) |
| 1003 | |
| 1004 | if (!response.ok) { |
| 1005 | const responseJson = (await response.json()) as { error?: string } |
| 1006 | throw new Error(`App token exchange failed: ${response.status} ${response.statusText} - ${responseJson.error}`) |
| 1007 | } |
| 1008 | |
| 1009 | const responseJson = (await response.json()) as { token: string } |
| 1010 | return responseJson.token |
| 1011 | } |
| 1012 | |
| 1013 | async function configureGit(appToken: string) { |
| 1014 | // Do not change git config when running locally |
no test coverage detected