From 85e34eb80c788a67dffb46b1f742329c6a72939d Mon Sep 17 00:00:00 2001 From: pngwn Date: Tue, 6 Aug 2024 20:51:05 +0100 Subject: [PATCH] changes --- packages/filter-paths/index.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/filter-paths/index.ts b/packages/filter-paths/index.ts index 44e2090..4a2a095 100644 --- a/packages/filter-paths/index.ts +++ b/packages/filter-paths/index.ts @@ -26,16 +26,28 @@ async function run() { const filter = filters[filter_name]; let files: any[] = []; - for await (const response of octokit.paginate.iterator( - octokit.rest.pulls.listFiles, - { + + if (context.payload.event_name === "pull_request") { + for await (const response of octokit.paginate.iterator( + octokit.rest.pulls.listFiles, + { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request?.number as number, + per_page: 100, + } + )) { + files = [...files, ...parse_data(response.data)]; + } + } else if (context.payload.event_name === "push") { + const response = await octokit.rest.repos.getCommit({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: context.payload.pull_request?.number as number, - per_page: 100, - } - )) { - files = [...files, ...parse_data(response.data)]; + ref: context.ref, + }); + files = [...files, ...parse_data(response.data.files)]; + } else { + throw new Error("Unsupported event"); } files = files.map((f) => f.filename);