Skip to content

Commit 9bdcd79

Browse files
peter-evansjeaguil
andauthored
fix: paginate workflow discovery (#438)
* fix: paginate workflow discovery for repos with >30 workflows in workflow_dispatch commands (#437) * Fetch all workflows with paginate * Add page parameter when fetching all workflows * fix: formatting and dist --------- Co-authored-by: Jesus Aguilera <jeaguil@github.com>
1 parent 5c11dc7 commit 9bdcd79

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ class GitHubHelper {
391391
getWorkflow(repository, workflowName) {
392392
return __awaiter(this, void 0, void 0, function* () {
393393
core.debug(`Getting workflow ${workflowName} for repository ${repository}`);
394-
const { data: workflows } = yield this.octokit.rest.actions.listRepoWorkflows(Object.assign({}, this.parseRepository(repository)));
395-
for (const workflow of workflows.workflows) {
394+
const workflows = yield this.octokit.paginate('GET /repos/{owner}/{repo}/actions/workflows', Object.assign(Object.assign({}, this.parseRepository(repository)), { per_page: 100 }));
395+
for (const workflow of workflows) {
396396
core.debug(`Found workflow: ${workflow.path}`);
397397
if (workflow.path.endsWith(`${workflowName}.yml`) ||
398398
workflow.path.endsWith(`${workflowName}.yaml`)) {

src/github-helper.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,14 @@ export class GitHubHelper {
189189
workflowName: string
190190
): Promise<string> {
191191
core.debug(`Getting workflow ${workflowName} for repository ${repository}`)
192-
const {data: workflows} = await this.octokit.rest.actions.listRepoWorkflows(
192+
const workflows = await this.octokit.paginate(
193+
'GET /repos/{owner}/{repo}/actions/workflows',
193194
{
194-
...this.parseRepository(repository)
195+
...this.parseRepository(repository),
196+
per_page: 100
195197
}
196198
)
197-
for (const workflow of workflows.workflows) {
199+
for (const workflow of workflows) {
198200
core.debug(`Found workflow: ${workflow.path}`)
199201
if (
200202
workflow.path.endsWith(`${workflowName}.yml`) ||

0 commit comments

Comments
 (0)