Skip to content

Commit

Permalink
Better handling for required workflows
Browse files Browse the repository at this point in the history
Return the workflow path from the run rather than trying to fetch the workflow
information when the workflow information is missing or refers to a required workflow.
  • Loading branch information
Marco Gario committed Jun 27, 2024
1 parent 9b7c22c commit 37b6ead
Show file tree
Hide file tree
Showing 3 changed files with 16 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.

8 changes: 8 additions & 0 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ export async function getWorkflowRelativePath(): Promise<string> {
);
const workflowUrl = runsResponse.data.workflow_url;

const requiredWorkflowRegex = /\/repos\/[^/]+\/[^/]+\/actions\/required_workflows\/[^/]+/;
if (!workflowUrl || 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 as string;
}

const workflowResponse = await apiClient.request(`GET ${workflowUrl}`);

return workflowResponse.data.path as string;
Expand Down

0 comments on commit 37b6ead

Please sign in to comment.