Skip to content

Commit 816de1b

Browse files
authored
Fix workflow_run reference in entropy comment workflow
Didn't trigger on external PRs, Claude Fable fix. Grok is not very good with these.
1 parent d36352f commit 816de1b

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

.github/workflows/entropy-beauty-comment.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: Post Entropy Beauty Comment
22

33
on:
44
workflow_run:
5-
workflows: ["Entropy Beauty + TruffleHog Scan"]
5+
# The workflows filter is a glob pattern: '+' is a quantifier there,
6+
# so a literal plus sign in the workflow name must be escaped with \+
7+
workflows: ['Entropy Beauty \+ TruffleHog Scan']
68
types: [completed]
79

810
permissions:
@@ -58,19 +60,23 @@ jobs:
5860
5961
body += `\n*Mid-4 beauty heuristic in action — powered by our entropy chats! 😊*`;
6062
63+
// Inside github-script, `github` is the Octokit client;
64+
// the event payload lives on context.payload.
65+
const workflowRun = context.payload.workflow_run;
66+
6167
// Robust PR number lookup
6268
let prNumber = null;
63-
const prs = github.event.workflow_run.pull_requests || [];
69+
const prs = workflowRun.pull_requests || [];
6470
if (prs.length > 0) {
6571
prNumber = prs[0].number;
6672
} else {
67-
// Fallback: look up open PRs by head SHA
68-
const headSha = github.event.workflow_run.head_sha;
73+
// Fallback: workflow_run.pull_requests is empty for fork PRs,
74+
// so look up open PRs by head "owner:branch"
6975
const { data: found } = await github.rest.pulls.list({
7076
owner: context.repo.owner,
7177
repo: context.repo.repo,
7278
state: 'open',
73-
head: `${github.event.workflow_run.head_repository.owner.login}:${github.event.workflow_run.head_branch}`
79+
head: `${workflowRun.head_repository.owner.login}:${workflowRun.head_branch}`
7480
});
7581
if (found.length > 0) {
7682
prNumber = found[0].number;
@@ -79,7 +85,7 @@ jobs:
7985
8086
if (!prNumber) {
8187
console.log('No associated PR found (even after fallback lookup)');
82-
console.log(JSON.stringify(github.event.workflow_run, null, 2));
88+
console.log(JSON.stringify(workflowRun, null, 2));
8389
return;
8490
}
8591

0 commit comments

Comments
 (0)