Skip to content

Commit 958d3a0

Browse files
committed
Paginate workflows
1 parent 24cd42a commit 958d3a0

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/pinnedWorkflows/pinnedWorkflows.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import {getGitHubContextForWorkspaceUri, GitHubRepoContext} from "../git/repository";
1010

1111
import {sep} from "path";
12-
import {logError} from "../log";
12+
import {log, logError} from "../log";
1313
import {Workflow} from "../model";
1414
import {RunStore} from "../store/store";
1515
import {WorkflowRun} from "../store/workflowRun";
@@ -105,15 +105,25 @@ async function updatePinnedWorkflows() {
105105
}
106106

107107
// Get all workflows to resolve names. We could do this locally, but for now, let's make the API call.
108-
const workflows = await gitHubRepoContext.client.actions.listRepoWorkflows({
109-
owner: gitHubRepoContext.owner,
110-
repo: gitHubRepoContext.name
111-
});
108+
const workflows = await gitHubRepoContext.client.paginate(
109+
gitHubRepoContext.client.actions.listRepoWorkflows,
110+
{
111+
owner: gitHubRepoContext.owner,
112+
repo: gitHubRepoContext.name,
113+
per_page: 100
114+
},
115+
response => response.data
116+
);
112117

113118
const workflowByPath: {[id: string]: Workflow} = {};
114-
workflows.data.workflows.forEach(w => (workflowByPath[w.path] = w));
119+
workflows.forEach(w => (workflowByPath[w.path] = w));
115120

116121
for (const pinnedWorkflow of workflowsByWorkspace.get(workspaceName) || []) {
122+
if (!workflowByPath[pinnedWorkflow]) {
123+
log(`Unable to find pinned workflow ${pinnedWorkflow} in ${workspaceName}, ignoring`);
124+
continue;
125+
}
126+
117127
const pW = createPinnedWorkflow(gitHubRepoContext, workflowByPath[pinnedWorkflow]);
118128
await refreshPinnedWorkflow(pW);
119129
}

0 commit comments

Comments
 (0)