mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
sessions: add rerun action for failed CI checks in PR checks view (#306347)
Add a per-check rerun button for failed CI checks in the changes view. Uses the GitHub Actions rerun-failed-jobs API, extracting the workflow run ID from the check's detailsUrl. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
64e73b0366
commit
af50a47c13
@@ -60,6 +60,20 @@ export class GitHubPullRequestCIModel extends Disposable {
|
||||
return this._fetcher.getCheckRunAnnotations(this.owner, this.repo, checkRunId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rerun a failed check by extracting the workflow run ID from its details URL
|
||||
* and calling the GitHub Actions rerun-failed-jobs API, then refresh status.
|
||||
*/
|
||||
async rerunFailedCheck(check: IGitHubCICheck): Promise<void> {
|
||||
const runId = parseWorkflowRunId(check.detailsUrl);
|
||||
if (!runId) {
|
||||
this._logService.warn(`${LOG_PREFIX} Cannot rerun check "${check.name}": no workflow run ID found in detailsUrl`);
|
||||
return;
|
||||
}
|
||||
await this._fetcher.rerunFailedJobs(this.owner, this.repo, runId);
|
||||
await this.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start periodic polling. Each cycle refreshes CI check data.
|
||||
*/
|
||||
@@ -88,3 +102,16 @@ export class GitHubPullRequestCIModel extends Disposable {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the GitHub Actions workflow run ID from a check run's details URL.
|
||||
* URLs follow the pattern: `https://github.com/{owner}/{repo}/actions/runs/{run_id}/job/{job_id}`
|
||||
*/
|
||||
function parseWorkflowRunId(detailsUrl: string | undefined): number | undefined {
|
||||
if (!detailsUrl) {
|
||||
return undefined;
|
||||
}
|
||||
const match = /\/actions\/runs\/(?<runId>\d+)/.exec(detailsUrl);
|
||||
const runId = match?.groups?.runId;
|
||||
return runId ? parseInt(runId, 10) : undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user