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:
committed by
pullfrog[bot]
parent
df3ec6b815
commit
4ecff49b72
@@ -143434,6 +143434,20 @@ function CreatePullRequestTool(ctx) {
|
|||||||
head: currentBranch,
|
head: currentBranch,
|
||||||
base
|
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
pullRequestId: result.data.id,
|
pullRequestId: result.data.id,
|
||||||
@@ -146638,6 +146652,7 @@ var JsonPayload = type({
|
|||||||
version: "string",
|
version: "string",
|
||||||
"agent?": AgentName.or("undefined"),
|
"agent?": AgentName.or("undefined"),
|
||||||
prompt: "string",
|
prompt: "string",
|
||||||
|
"triggeringUser?": "string | undefined",
|
||||||
"eventInstructions?": "string",
|
"eventInstructions?": "string",
|
||||||
"repoInstructions?": "string",
|
"repoInstructions?": "string",
|
||||||
"event?": "object",
|
"event?": "object",
|
||||||
@@ -146701,6 +146716,9 @@ function resolveNonPromptInputs() {
|
|||||||
bash: core4.getInput("bash") || void 0
|
bash: core4.getInput("bash") || void 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var isPullfrog = (actor) => {
|
||||||
|
return !!actor && (actor === "pullfrog" || actor === "pullfrog[bot]");
|
||||||
|
};
|
||||||
function resolvePayload(resolvedPromptInput, repoSettings) {
|
function resolvePayload(resolvedPromptInput, repoSettings) {
|
||||||
const [prompt, jsonPayload] = typeof resolvedPromptInput !== "string" ? [resolvedPromptInput.prompt, resolvedPromptInput] : [resolvedPromptInput, void 0];
|
const [prompt, jsonPayload] = typeof resolvedPromptInput !== "string" ? [resolvedPromptInput.prompt, resolvedPromptInput] : [resolvedPromptInput, void 0];
|
||||||
const inputs = resolveNonPromptInputs();
|
const inputs = resolveNonPromptInputs();
|
||||||
@@ -146726,6 +146744,8 @@ function resolvePayload(resolvedPromptInput, repoSettings) {
|
|||||||
version: jsonPayload?.version ?? package_default.version,
|
version: jsonPayload?.version ?? package_default.version,
|
||||||
agent: resolvedAgent,
|
agent: resolvedAgent,
|
||||||
prompt,
|
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,
|
eventInstructions: jsonPayload?.eventInstructions,
|
||||||
repoInstructions: jsonPayload?.repoInstructions,
|
repoInstructions: jsonPayload?.repoInstructions,
|
||||||
event,
|
event,
|
||||||
|
|||||||
@@ -272,6 +272,8 @@ export interface WriteablePayload {
|
|||||||
agent?: AgentName | undefined;
|
agent?: AgentName | undefined;
|
||||||
/** the user's actual request (body if @pullfrog tagged) */
|
/** the user's actual request (body if @pullfrog tagged) */
|
||||||
prompt: string;
|
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) */
|
/** event-level instructions for this trigger type (flag-expanded server-side) */
|
||||||
eventInstructions?: string | undefined;
|
eventInstructions?: string | undefined;
|
||||||
/** repo-level instructions (flag-expanded server-side) */
|
/** repo-level instructions (flag-expanded server-side) */
|
||||||
|
|||||||
@@ -44,6 +44,22 @@ export function CreatePullRequestTool(ctx: ToolContext) {
|
|||||||
base: base,
|
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
pullRequestId: result.data.id,
|
pullRequestId: result.data.id,
|
||||||
|
|||||||
@@ -41378,6 +41378,7 @@ var JsonPayload = type({
|
|||||||
version: "string",
|
version: "string",
|
||||||
"agent?": AgentName.or("undefined"),
|
"agent?": AgentName.or("undefined"),
|
||||||
prompt: "string",
|
prompt: "string",
|
||||||
|
"triggeringUser?": "string | undefined",
|
||||||
"eventInstructions?": "string",
|
"eventInstructions?": "string",
|
||||||
"repoInstructions?": "string",
|
"repoInstructions?": "string",
|
||||||
"event?": "object",
|
"event?": "object",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const JsonPayload = type({
|
|||||||
version: "string",
|
version: "string",
|
||||||
"agent?": AgentName.or("undefined"),
|
"agent?": AgentName.or("undefined"),
|
||||||
prompt: "string",
|
prompt: "string",
|
||||||
|
"triggeringUser?": "string | undefined",
|
||||||
"eventInstructions?": "string",
|
"eventInstructions?": "string",
|
||||||
"repoInstructions?": "string",
|
"repoInstructions?": "string",
|
||||||
"event?": "object",
|
"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(
|
export function resolvePayload(
|
||||||
resolvedPromptInput: ResolvedPromptInput,
|
resolvedPromptInput: ResolvedPromptInput,
|
||||||
repoSettings: RepoSettings
|
repoSettings: RepoSettings
|
||||||
@@ -161,6 +166,10 @@ export function resolvePayload(
|
|||||||
version: jsonPayload?.version ?? packageJson.version,
|
version: jsonPayload?.version ?? packageJson.version,
|
||||||
agent: resolvedAgent,
|
agent: resolvedAgent,
|
||||||
prompt,
|
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,
|
eventInstructions: jsonPayload?.eventInstructions,
|
||||||
repoInstructions: jsonPayload?.repoInstructions,
|
repoInstructions: jsonPayload?.repoInstructions,
|
||||||
event,
|
event,
|
||||||
|
|||||||
Reference in New Issue
Block a user