Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/agentic_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ on:
types: [edited, labeled, opened, reopened]
issue_comment:
types: [created, edited]
pull_request:
pull_request_target:
types: [edited, labeled, opened, reopened]
pull_request_review_comment:
types: [created, edited]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-closed-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Label Closed PRs

# Trigger when a pull request is closed (either merged or without merging)
on:
pull_request:
pull_request_target:
types: [closed]

permissions:
Expand Down
70 changes: 36 additions & 34 deletions .github/workflows/pr-description-caveman.lock.yml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion .github/workflows/pr-description-caveman.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ private: true
name: PR Description Updater
description: Rewrites a merged PR description with a structured, considered summary optimised for downstream agentic analysis. Processes the full diff in chunks using sub-agents. Ignores lock files and auto-generated code.
on:
pull_request:
pull_request_target:
types: [closed]
if: github.event.pull_request.merged == true && !startsWith(github.event.pull_request.head.ref, 'signed/jsweep/') && !startsWith(github.event.pull_request.head.ref, 'copilot/')
checkout:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.base.sha }}
fetch-depth: 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b6a2da5: added an explicit git fetch origin "refs/pull/${PR_NUMBER}/head:refs/gh-aw/pr-${PR_NUMBER}/head" before the diff commands so the fork's head commit is present locally without checking it out.

permissions:
contents: read
pull-requests: read
Expand Down
7 changes: 6 additions & 1 deletion actions/setup/js/route_slash_command.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ async function appendRoutingSummary(existingCommands, selectedCommand) {
}

function eventIdentifier() {
if (context.eventName === "pull_request_target") {
return "pull_request";
Comment on lines +46 to +47

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b6a2da5: both dispatch paths now override event_type with the normalized identifier before serializing aw_context, and the pull_request_target test asserts awContext.event_type === "pull_request".

}
if (context.eventName !== "issue_comment") {
return context.eventName;
}
Expand All @@ -53,6 +56,7 @@ function resolveBodyText() {
const bodyByEvent = {
issues: context.payload?.issue?.body ?? "",
pull_request: context.payload?.pull_request?.body ?? "",
pull_request_target: context.payload?.pull_request?.body ?? "",
issue_comment: context.payload?.comment?.body ?? "",
pull_request_review_comment: context.payload?.comment?.body ?? "",
pull_request_review: context.payload?.review?.body ?? "",
Expand Down Expand Up @@ -215,7 +219,8 @@ async function addImmediateReaction(reaction) {
});
return;
}
case "pull_request": {
case "pull_request":
case "pull_request_target": {
const prNumber = context.payload?.pull_request?.number;
if (!prNumber) {
core.warning("Skipping immediate reaction: pull request number was not found in payload.");
Expand Down
13 changes: 13 additions & 0 deletions actions/setup/js/route_slash_command.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,19 @@ describe("route_slash_command", () => {
expect(reactionCalls[0][0]).toBe("POST /repos/{owner}/{repo}/issues/{issue_number}/reactions");
});

it("treats pull_request_target events as pull_request routes", async () => {
globals.context.eventName = "pull_request_target";
globals.context.payload = { pull_request: { number: 7, body: "/archie please" } };
process.env.GH_AW_SLASH_ROUTING = JSON.stringify({
archie: [{ workflow: "archie", events: ["pull_request"], ai_reaction: "eyes" }],
});
await main();
expect(dispatchCalls).toHaveLength(1);
expect(reactionCalls).toHaveLength(1);
const awContext = JSON.parse(dispatchCalls[0].inputs.aw_context);
expect(awContext.command_name).toBe("archie");
});

it("adds immediate reaction for pull_request_review_comment events using comment id", async () => {
globals.context.eventName = "pull_request_review_comment";
globals.context.payload = { comment: { id: 99, body: "/archie please" } };
Expand Down
6 changes: 5 additions & 1 deletion pkg/workflow/central_slash_command_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,11 @@ func writeCentralSlashEventsYAML(b *strings.Builder, mergedEvents map[string]map
continue
}
types := sliceutil.SortedKeys(typeSet)
b.WriteString(" " + eventName + ":\n")
yamlEventName := eventName
if eventName == "pull_request" {
yamlEventName = "pull_request_target"
}
b.WriteString(" " + yamlEventName + ":\n")
b.WriteString(" types: [" + strings.Join(types, ", ") + "]\n")
}
}
6 changes: 4 additions & 2 deletions pkg/workflow/central_slash_command_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ func TestGenerateCentralSlashCommandWorkflow_GeneratesWorkflow(t *testing.T) {
require.Contains(t, text, " destination: ${{ runner.temp }}/gh-aw/actions")
require.Contains(t, text, "issues:")
require.Contains(t, text, "issue_comment:")
require.Contains(t, text, "pull_request:")
require.Contains(t, text, "pull_request_target:")
require.NotContains(t, text, "\n pull_request:\n")
require.Contains(t, text, "discussion_comment:")
require.Contains(t, text, `"triage":[{"workflow":"triage-issue","events":["issue_comment","issues"],"ai_reaction":"eyes","status_comment":true},{"workflow":"triage-pr","events":["pull_request","pull_request_comment"],"ai_reaction":"rocket","status_comment":true}]`)
require.Contains(t, text, `"cloclo":[{"workflow":"cloclo","events":["discussion_comment"],"ai_reaction":"heart","status_comment":true}]`)
Expand Down Expand Up @@ -202,7 +203,8 @@ func TestGenerateCentralSlashCommandWorkflow_GeneratesForDecentralizedLabelsOnly
text := string(content)
require.Contains(t, text, "GH_AW_LABEL_ROUTING")
require.Contains(t, text, `"ci-doctor":[{"workflow":"ci-doctor","events":["pull_request"]}]`)
require.Contains(t, text, "pull_request:")
require.Contains(t, text, "pull_request_target:")
require.NotContains(t, text, "\n pull_request:\n")
require.Contains(t, text, "types: [labeled]")
require.Contains(t, text, "# slash commands:")
require.Contains(t, text, "# (none)")
Expand Down
Loading