From 26c4779bf2b2454dcc0788a862227b2f3647aa0d Mon Sep 17 00:00:00 2001 From: Tobias Wilken Date: Mon, 22 Dec 2025 22:54:14 +0100 Subject: [PATCH] fix: use GitHub Actions API for workflow re-runs Replace Check Runs API with Actions API for re-running workflows after accepting repository invitations. The Check Runs API is designed for GitHub Apps while the Actions API properly re-runs GitHub Actions workflows. Changes: - Use /actions/runs endpoint to find failed workflows by head SHA - Use /actions/runs/{id}/rerun to trigger re-runs - Filter for failed status to only re-run relevant workflows --- src/helpers/invitationProcessor.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/helpers/invitationProcessor.js b/src/helpers/invitationProcessor.js index e41122d..af5e3c5 100644 --- a/src/helpers/invitationProcessor.js +++ b/src/helpers/invitationProcessor.js @@ -166,9 +166,10 @@ async function triggerDocumentationPRChecks(token, acceptedRepos) { } ); - // Trigger workflow re-run by re-requesting check runs - const checksResponse = await fetch( - `${GITHUB_API_BASE}/repos/${DOCUMENTATION_REPO}/commits/${pr.head.sha}/check-runs`, + // Trigger workflow re-run using GitHub Actions API + // Find the most recent workflow run for this PR's head SHA + const runsResponse = await fetch( + `${GITHUB_API_BASE}/repos/${DOCUMENTATION_REPO}/actions/runs?head_sha=${pr.head.sha}&status=failure`, { headers: { Authorization: `Bearer ${token}`, @@ -177,12 +178,12 @@ async function triggerDocumentationPRChecks(token, acceptedRepos) { } ); - if (checksResponse.ok) { - const checks = await checksResponse.json(); - for (const check of checks.check_runs || []) { - // Re-run the check - await fetch( - `${GITHUB_API_BASE}/repos/${DOCUMENTATION_REPO}/check-runs/${check.id}/rerequest`, + if (runsResponse.ok) { + const runs = await runsResponse.json(); + for (const run of runs.workflow_runs || []) { + // Re-run the failed workflow + const rerunResponse = await fetch( + `${GITHUB_API_BASE}/repos/${DOCUMENTATION_REPO}/actions/runs/${run.id}/rerun`, { method: 'POST', headers: { @@ -191,6 +192,16 @@ async function triggerDocumentationPRChecks(token, acceptedRepos) { }, } ); + + if (rerunResponse.ok || rerunResponse.status === 201) { + console.log( + `[Invitations] ✅ Re-triggered workflow run ${run.id} for PR #${pr.number}` + ); + } else { + console.error( + `[Invitations] ❌ Failed to re-run workflow ${run.id}: ${rerunResponse.status}` + ); + } } } }