@@ -47,32 +47,45 @@ jobs:
4747 'langchain-python-sdk-pr-',
4848 'llamaindex-python-sdk-pr-',
4949 ];
50- const prList = context.payload.check_suite.pull_requests;
51- if (!prList || prList.length === 0) {
52- core.info('No PR found for this check suite. Skipping.');
53- core.setOutput('failure_detected', 'false');
54- return;
55- }
56- const pr_number = prList[0].number;
57- core.setOutput('pr_number', pr_number.toString());
58- const { owner, repo } = context.repo;
59- const sha = context.payload.check_suite.head_sha;
60- const { data: checks } = await github.rest.checks.listForRef({ owner, repo, ref: sha, per_page: 100 });
50+ let pr_number = undefined;
51+ const { owner, repo } = context.repo;
52+ const sha = context.payload.check_suite.head_sha;
53+ if (context.payload.check_suite && context.payload.check_suite.pull_requests && context.payload.check_suite.pull_requests.length > 0) {
54+ pr_number = context.payload.check_suite.pull_requests[0].number;
55+ }
56+ if (!pr_number) {
57+ const { data: prs } = await github.rest.pulls.list({
58+ owner,
59+ repo,
60+ state: 'open',
61+ per_page: 100
62+ });
63+ const match = prs.find(pr => pr.head && pr.head.sha === sha);
64+ if (match) {
65+ pr_number = match.number;
66+ }
67+ }
68+ if (!pr_number) {
69+ core.info('No PR found for this check suite or commit. Skipping.');
70+ core.setOutput('failure_detected', 'false');
71+ return;
72+ }
73+ core.setOutput('pr_number', pr_number.toString());
74+ const { data: checks } = await github.rest.checks.listForRef({ owner, repo, ref: sha, per_page: 100 });
6175 const failed = checks.check_runs.filter(
62- c =>
76+ c =>
6377 prefixes.some(prefix => c.name.startsWith(prefix)) &&
6478 c.status === 'completed' &&
6579 c.conclusion === 'failure'
6680 );
6781 if (failed.length === 0) {
68- core.info('No failed Cloud Build checks detected.');
69- core.setOutput('failure_detected', 'false');
70- return;
82+ core.info('No failed Cloud Build checks detected.');
83+ core.setOutput('failure_detected', 'false');
84+ return;
7185 }
7286 core.info(`Detected ${failed.length} failed build(s).`);
7387 core.setOutput('failure_detected', 'true');
7488 core.setOutput('failed_checks', JSON.stringify(failed.map(f => ({ name: f.name, id: f.id, html_url: f.html_url, details_url: f.details_url, external_id: f.external_id || '' }))));
75-
7689
7790 process-failed-builds :
7891 needs : detect-build-failure
0 commit comments