Skip to content

Commit 37b6ead

Browse files
committed
Better handling for required workflows
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.
1 parent 9b7c22c commit 37b6ead

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/api-client.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api-client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api-client.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ export async function getWorkflowRelativePath(): Promise<string> {
139139
);
140140
const workflowUrl = runsResponse.data.workflow_url;
141141

142+
const requiredWorkflowRegex = /\/repos\/[^/]+\/[^/]+\/actions\/required_workflows\/[^/]+/;
143+
if (!workflowUrl || workflowUrl === "" || requiredWorkflowRegex.test(workflowUrl)) {
144+
// For required workflows, the workflowUrl is invalid so we cannot fetch more informations
145+
// about the workflow.
146+
// However, the path is available in the original response.
147+
return runsResponse.data.path as string;
148+
}
149+
142150
const workflowResponse = await apiClient.request(`GET ${workflowUrl}`);
143151

144152
return workflowResponse.data.path as string;

0 commit comments

Comments
 (0)