Request reviews from the PR's human initiator (#340)

* Request reviews from the PR's human initiator

* add logs

* await the request reviewers call
This commit is contained in:
Mateusz Burzyński
2026-02-19 14:00:57 +00:00
committed by pullfrog[bot]
parent df3ec6b815
commit 4ecff49b72
5 changed files with 48 additions and 0 deletions
+20
View File
@@ -143434,6 +143434,20 @@ function CreatePullRequestTool(ctx) {
head: currentBranch,
base
});
const reviewer = ctx.payload.triggeringUser;
if (reviewer) {
try {
log.debug(`Requesting review from ${reviewer} on PR #${result.data.number}`);
await ctx.octokit.rest.pulls.requestReviewers({
owner: ctx.repo.owner,
repo: ctx.repo.name,
pull_number: result.data.number,
reviewers: [reviewer]
});
} catch {
log.info(`failed to request review from ${reviewer} on PR #${result.data.number}`);
}
}
return {
success: true,
pullRequestId: result.data.id,
@@ -146638,6 +146652,7 @@ var JsonPayload = type({
version: "string",
"agent?": AgentName.or("undefined"),
prompt: "string",
"triggeringUser?": "string | undefined",
"eventInstructions?": "string",
"repoInstructions?": "string",
"event?": "object",
@@ -146701,6 +146716,9 @@ function resolveNonPromptInputs() {
bash: core4.getInput("bash") || void 0
});
}
var isPullfrog = (actor) => {
return !!actor && (actor === "pullfrog" || actor === "pullfrog[bot]");
};
function resolvePayload(resolvedPromptInput, repoSettings) {
const [prompt, jsonPayload] = typeof resolvedPromptInput !== "string" ? [resolvedPromptInput.prompt, resolvedPromptInput] : [resolvedPromptInput, void 0];
const inputs = resolveNonPromptInputs();
@@ -146726,6 +146744,8 @@ function resolvePayload(resolvedPromptInput, repoSettings) {
version: jsonPayload?.version ?? package_default.version,
agent: resolvedAgent,
prompt,
triggeringUser: jsonPayload?.triggeringUser ?? // it's not a common use case but GITHUB_ACTOR can be a user when the workflow is manually triggered by a user through GitHub Actions UI
(!isPullfrog(process.env.GITHUB_ACTOR) ? process.env.GITHUB_ACTOR : void 0),
eventInstructions: jsonPayload?.eventInstructions,
repoInstructions: jsonPayload?.repoInstructions,
event,
+2
View File
@@ -272,6 +272,8 @@ export interface WriteablePayload {
agent?: AgentName | undefined;
/** the user's actual request (body if @pullfrog tagged) */
prompt: string;
/** github username of the human who triggered this workflow run */
triggeringUser?: string | undefined;
/** event-level instructions for this trigger type (flag-expanded server-side) */
eventInstructions?: string | undefined;
/** repo-level instructions (flag-expanded server-side) */
+16
View File
@@ -44,6 +44,22 @@ export function CreatePullRequestTool(ctx: ToolContext) {
base: base,
});
// best-effort: request review from the user who triggered the workflow
const reviewer = ctx.payload.triggeringUser;
if (reviewer) {
try {
log.debug(`Requesting review from ${reviewer} on PR #${result.data.number}`);
await ctx.octokit.rest.pulls.requestReviewers({
owner: ctx.repo.owner,
repo: ctx.repo.name,
pull_number: result.data.number,
reviewers: [reviewer],
});
} catch {
log.info(`failed to request review from ${reviewer} on PR #${result.data.number}`);
}
}
return {
success: true,
pullRequestId: result.data.id,
+1
View File
@@ -41378,6 +41378,7 @@ var JsonPayload = type({
version: "string",
"agent?": AgentName.or("undefined"),
prompt: "string",
"triggeringUser?": "string | undefined",
"eventInstructions?": "string",
"repoInstructions?": "string",
"event?": "object",
+9
View File
@@ -19,6 +19,7 @@ export const JsonPayload = type({
version: "string",
"agent?": AgentName.or("undefined"),
prompt: "string",
"triggeringUser?": "string | undefined",
"eventInstructions?": "string",
"repoInstructions?": "string",
"event?": "object",
@@ -108,6 +109,10 @@ function resolveNonPromptInputs() {
});
}
const isPullfrog = (actor: string | null | undefined): boolean => {
return !!actor && (actor === "pullfrog" || actor === "pullfrog[bot]");
};
export function resolvePayload(
resolvedPromptInput: ResolvedPromptInput,
repoSettings: RepoSettings
@@ -161,6 +166,10 @@ export function resolvePayload(
version: jsonPayload?.version ?? packageJson.version,
agent: resolvedAgent,
prompt,
triggeringUser:
jsonPayload?.triggeringUser ??
// it's not a common use case but GITHUB_ACTOR can be a user when the workflow is manually triggered by a user through GitHub Actions UI
(!isPullfrog(process.env.GITHUB_ACTOR) ? process.env.GITHUB_ACTOR : undefined),
eventInstructions: jsonPayload?.eventInstructions,
repoInstructions: jsonPayload?.repoInstructions,
event,