feat: implement auto-merge for approved PRs and update workflow documentation
This commit is contained in:
@@ -152,6 +152,15 @@ export class GitHubProvider implements IssueProvider {
|
||||
return { state: PrState.CLOSED, url: null };
|
||||
}
|
||||
|
||||
async mergePr(issueId: number): Promise<void> {
|
||||
const pat = `#${issueId}`;
|
||||
const raw = await this.gh(["pr", "list", "--state", "open", "--json", "number,title,body,url", "--limit", "20"]);
|
||||
const prs = JSON.parse(raw) as Array<{ number: number; title: string; body: string; url: string }>;
|
||||
const pr = prs.find((p) => p.title.includes(pat) || (p.body ?? "").includes(pat));
|
||||
if (!pr) throw new Error(`No open PR found for issue #${issueId}`);
|
||||
await this.gh(["pr", "merge", pr.url, "--merge"]);
|
||||
}
|
||||
|
||||
async addComment(issueId: number, body: string): Promise<void> {
|
||||
await this.gh(["issue", "comment", String(issueId), "--body", body]);
|
||||
}
|
||||
|
||||
@@ -149,6 +149,15 @@ export class GitLabProvider implements IssueProvider {
|
||||
return { state: PrState.CLOSED, url: null };
|
||||
}
|
||||
|
||||
async mergePr(issueId: number): Promise<void> {
|
||||
const pat = `#${issueId}`;
|
||||
const raw = await this.glab(["mr", "list", "--output", "json", "--state", "opened"]);
|
||||
const mrs = JSON.parse(raw) as Array<{ iid: number; title: string; description: string }>;
|
||||
const mr = mrs.find((m) => m.title.includes(pat) || (m.description ?? "").includes(pat));
|
||||
if (!mr) throw new Error(`No open MR found for issue #${issueId}`);
|
||||
await this.glab(["mr", "merge", String(mr.iid)]);
|
||||
}
|
||||
|
||||
async addComment(issueId: number, body: string): Promise<void> {
|
||||
// Pass message directly as argv — no shell escaping needed with spawn
|
||||
await this.glab(["issue", "note", String(issueId), "--message", body]);
|
||||
|
||||
@@ -61,6 +61,7 @@ export interface IssueProvider {
|
||||
hasMergedMR(issueId: number): Promise<boolean>;
|
||||
getMergedMRUrl(issueId: number): Promise<string | null>;
|
||||
getPrStatus(issueId: number): Promise<PrStatus>;
|
||||
mergePr(issueId: number): Promise<void>;
|
||||
addComment(issueId: number, body: string): Promise<void>;
|
||||
healthCheck(): Promise<boolean>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user