Skip to content

Commit c059055

Browse files
author
Chloé
committed
fix: add workflow_run trigger for fork PR triage notifications
- Remove PR handling from chloe-triage.yml (issues & comments only) - Add triage-on-pr-completion.yml to handle fork PRs via workflow_run - workflow_run runs in base repo context with full secret access - Only triggers for fork PRs, no approval needed
1 parent ccfd0ce commit c059055

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

.github/workflows/chloe-triage.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
types: [opened]
66
issue_comment:
77
types: [created]
8-
pull_request_target:
9-
types: [opened]
108

119
jobs:
1210
notify:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Triage on Fork PR Completion
2+
3+
# Only triggers on fork PRs (external contributors)
4+
# Runs in base repo context with full secret access
5+
on:
6+
workflow_run:
7+
workflows: ["Pull Requests"]
8+
types: [completed]
9+
10+
jobs:
11+
triage:
12+
runs-on: ubuntu-latest
13+
if: github.event.workflow_run.head_repository.fork == true
14+
steps:
15+
- name: Send fork PR triage notification
16+
env:
17+
HOOK_URL: ${{ secrets.OPENCLAW_HOOK_URL }}
18+
HOOK_TOKEN: ${{ secrets.OPENCLAW_HOOK_TOKEN }}
19+
run: |
20+
# Fetch PR details from completed workflow
21+
PR_DATA=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} \
22+
--jq '.pull_requests[0] | {number, title, html_url, user: .head.user.login}')
23+
24+
PR_NUMBER=$(echo "$PR_DATA" | jq -r '.number // empty')
25+
[ -z "$PR_NUMBER" ] && exit 0
26+
27+
PR_TITLE=$(echo "$PR_DATA" | jq -r '.title')
28+
PR_URL=$(echo "$PR_DATA" | jq -r '.html_url')
29+
PR_AUTHOR=$(echo "$PR_DATA" | jq -r '.user')
30+
31+
MSG="PR #${PR_NUMBER}: ${PR_TITLE}"$'\n'"Author: ${PR_AUTHOR}"$'\n'"URL: ${PR_URL}"
32+
33+
PAYLOAD=$(jq -n \
34+
--arg message "$MSG" \
35+
--arg name "GitHub Triage" \
36+
'{message: $message, name: $name, deliver: true, channel: "discord", to: "1474759623209783327"}')
37+
38+
curl -sf -X POST \
39+
-H "Authorization: Bearer ${HOOK_TOKEN}" \
40+
-H "Content-Type: application/json" \
41+
-d "$PAYLOAD" \
42+
"$HOOK_URL"
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)