Merge pull request #2356 from github/marcogario/require_workflows_path

Better handling for required workflows
This commit is contained in:
Marco Gario 2024-07-01 14:58:39 +02:00 committed by GitHub
commit ee4ad8b9d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

7
lib/api-client.js generated
View file

@ -123,6 +123,13 @@ async function getWorkflowRelativePath() {
run_id,
});
const workflowUrl = runsResponse.data.workflow_url;
const requiredWorkflowRegex = /\/repos\/[^/]+\/[^/]+\/actions\/required_workflows\/[^/]+/;
if (!workflowUrl || requiredWorkflowRegex.test(workflowUrl)) {
// For required workflows, the workflowUrl is invalid so we cannot fetch more informations
// about the workflow.
// However, the path is available in the original response.
return runsResponse.data.path;
}
const workflowResponse = await apiClient.request(`GET ${workflowUrl}`);
return workflowResponse.data.path;
}

File diff suppressed because one or more lines are too long

View file

@ -139,6 +139,15 @@ export async function getWorkflowRelativePath(): Promise<string> {
);
const workflowUrl = runsResponse.data.workflow_url;
const requiredWorkflowRegex =
/\/repos\/[^/]+\/[^/]+\/actions\/required_workflows\/[^/]+/;
if (!workflowUrl || requiredWorkflowRegex.test(workflowUrl as string)) {
// For required workflows, the workflowUrl is invalid so we cannot fetch more informations
// about the workflow.
// However, the path is available in the original response.
return runsResponse.data.path as string;
}
const workflowResponse = await apiClient.request(`GET ${workflowUrl}`);
return workflowResponse.data.path as string;