cloudflare/kumo

Public

mirrored fromhttps://github.com/cloudflare/kumoAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
6dc9a73c0bb7ae2731f474f987d92742b4e3b764

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ci/utils/github-api.ts

64lines · modecode

1/**
2 * GitHub API utilities for pull request operations
3 *
4 * NOTE: Requires @octokit/rest package to be installed:
5 * pnpm add -D @octokit/rest
6 */
7
8import { Octokit } from "@octokit/rest";
9
10export const GITHUB_API_URL = "https://api.github.com";
11export const GITHUB_REPO_OWNER = "cloudflare";
12export const GITHUB_REPO_NAME = "kumo";
13
14/**
15 * Interface for pull request creation parameters
16 */
17export interface CreatePullRequestOptions {
18 sourceBranch: string;
19 targetBranch: string;
20 title: string;
21 description: string;
22}
23
24/**
25 * Create a pull request using GitHub API
26 */
27export async function createPullRequest(
28 token: string,
29 options: CreatePullRequestOptions,
30): Promise<{ number: number; html_url: string }> {
31 const octokit = new Octokit({ auth: token });
32
33 const pullRequest = await octokit.pulls.create({
34 owner: GITHUB_REPO_OWNER,
35 repo: GITHUB_REPO_NAME,
36 head: options.sourceBranch,
37 base: options.targetBranch,
38 title: options.title,
39 body: options.description,
40 });
41
42 return {
43 number: pullRequest.data.number,
44 html_url: pullRequest.data.html_url,
45 };
46}
47
48/**
49 * Post a comment to a pull request
50 */
51export async function postPRComment(
52 token: string,
53 prNumber: number,
54 body: string,
55): Promise<void> {
56 const octokit = new Octokit({ auth: token });
57
58 await octokit.issues.createComment({
59 owner: GITHUB_REPO_OWNER,
60 repo: GITHUB_REPO_NAME,
61 issue_number: prNumber,
62 body,
63 });
64}
65