({
githubToken,
...params
}: CreatePRConfig)
| 311 | }; |
| 312 | |
| 313 | export async function createPR({ |
| 314 | githubToken, |
| 315 | ...params |
| 316 | }: CreatePRConfig): Promise<PR> { |
| 317 | const response = await fetchWithRetries( |
| 318 | `https://api.github.com/repos/cloudflare/templates/pulls`, |
| 319 | { |
| 320 | method: "POST", |
| 321 | headers: { |
| 322 | "Content-Type": "application/json", |
| 323 | Authorization: `Bearer ${githubToken}`, |
| 324 | Connection: "close", |
| 325 | }, |
| 326 | body: JSON.stringify(params), |
| 327 | }, |
| 328 | ); |
| 329 | if (!response.ok) { |
| 330 | throw new Error( |
| 331 | `Error response from GitHub (${response.status}): ${await response.text()}`, |
| 332 | ); |
| 333 | } |
| 334 | return (await response.json()) as PR; |
| 335 | } |
| 336 | |
| 337 | export type GetPRByBranchConfig = { |
| 338 | githubToken: string; |
no test coverage detected