From b9afffe6fa6279fb8b94c68752b8921f8d6b46e3 Mon Sep 17 00:00:00 2001 From: Andrei Kashchikhin Date: Mon, 17 Jun 2024 21:50:52 +0100 Subject: [PATCH] [CI] [GHA] Rerun only failed jobs via rerunner (#25074) ### Tickets: - *142219* --- .github/scripts/workflow_rerun/rerunner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/scripts/workflow_rerun/rerunner.py b/.github/scripts/workflow_rerun/rerunner.py index f92130734c3fe6..b37f51e282a1cd 100644 --- a/.github/scripts/workflow_rerun/rerunner.py +++ b/.github/scripts/workflow_rerun/rerunner.py @@ -6,12 +6,14 @@ import tempfile from pathlib import Path +import requests from github import Github, Auth from workflow_rerun.argument_parser import get_arguments from workflow_rerun.constants import GITHUB_TOKEN, LOGGER from workflow_rerun.log_analyzer import LogAnalyzer from workflow_rerun.log_collector import collect_logs_for_run + if __name__ == '__main__': args = get_arguments() @@ -53,7 +55,12 @@ LOGGER.info(f'RUNNING IN DRY RUN MODE, NOT RETRIGGERING, EXITING') sys.exit(0) - status = run.rerun() + # PyGitHub does not expose the "/repos/{owner}/{repo}/actions/runs/RUN_ID/rerun-failed-jobs" endpoint + # so we have to use requests + response = requests.post(url=f'https://api.github.com/repos/{repository_name}/actions/runs/{run_id}/rerun-failed-jobs', + headers={'Authorization': f'Bearer {GITHUB_TOKEN}'}) + status = response.status_code == 201 + if status: LOGGER.info(f'RUN RETRIGGERED SUCCESSFULLY: {run.html_url}') else: