Skip to content

Commit

Permalink
Merge pull request #2356 from github/marcogario/require_workflows_path
Browse files Browse the repository at this point in the history
Better handling for required workflows
  • Loading branch information
marcogario authored Jul 1, 2024
2 parents 79e9a50 + ddd849e commit ee4ad8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/api-client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/api-client.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee4ad8b

Please sign in to comment.