Skip to content

Commit 70328e6

Browse files
committed
fix again
1 parent 3ba361e commit 70328e6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

scripts/ci/rerun_pr_workflows.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,24 @@ def dispatch_workflow(
8181

8282
def rerun_workflow(*, repo: str, token: str, run_id: int) -> None:
8383
rerun_url = f"https://api.github.com/repos/{repo}/actions/runs/{run_id}/rerun"
84-
github_request(rerun_url, token, method="POST", payload={})
84+
request = urllib.request.Request(
85+
rerun_url,
86+
data=json.dumps({}).encode("utf-8"),
87+
method="POST",
88+
)
89+
request.add_header("Authorization", f"Bearer {token}")
90+
request.add_header("Accept", "application/vnd.github+json")
91+
request.add_header("Content-Type", "application/json")
92+
try:
93+
with urllib.request.urlopen(request, timeout=30):
94+
return
95+
except urllib.error.HTTPError as exc:
96+
body = exc.read().decode("utf-8", errors="ignore")
97+
if exc.code == 403 and "already running" in body.lower():
98+
print(f" Run {run_id} is already in progress; skipping rerun request.")
99+
return
100+
print(f"GitHub API error ({exc.code}) for {rerun_url}:\n{body}", file=sys.stderr)
101+
raise
85102

86103

87104
def collect_runs(

0 commit comments

Comments
 (0)