From e4246d2b5b69b79c628db363499a0d3e3c8a8fa8 Mon Sep 17 00:00:00 2001 From: David Kale Date: Tue, 8 Sep 2020 12:37:50 -0400 Subject: [PATCH] Paginate to get all changed files. Add option to remove labels --- action.yml | 6 ++++++ src/main.ts | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index ad68c287..812eeb62 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,12 @@ inputs: configuration-path: description: 'The path for the label configurations' default: '.github/labeler.yml' + required: false + sync-labels: + description: 'Whether or not to remove labels when matching files are reverted' + default: false + required: false + runs: using: 'node12' main: 'lib/main.js' diff --git a/src/main.ts b/src/main.ts index 3b0fca42..de88b1ea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,7 @@ async function run() { try { const token = core.getInput('repo-token', {required: true}); const configPath = core.getInput('configuration-path', {required: true}); + const syncLabels = !!core.getInput("sync-labels", { required: false }); const prNumber = getPrNumber(); if (!prNumber) { @@ -16,6 +17,12 @@ async function run() { const client = new github.GitHub(token); + const { data: pullRequest } = await client.pulls.get({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + pull_number: prNumber + }); + core.debug(`fetching changed files for pr #${prNumber}`); const changedFiles: string[] = await getChangedFiles(client, prNumber); const labelGlobs: Map = await getLabelGlobs( @@ -53,13 +60,14 @@ async function getChangedFiles( client: github.GitHub, prNumber: number ): Promise { - const listFilesResponse = await client.pulls.listFiles({ + const listFilesOptions = client.pulls.listFiles.endpoint.merge({ owner: github.context.repo.owner, repo: github.context.repo.repo, pull_number: prNumber }); - const changedFiles = listFilesResponse.data.map(f => f.filename); + const listFilesResponse = await client.paginate(listFilesOptions); + const changedFiles = listFilesResponse.map(f => f.filename); core.debug('found changed files:'); for (const file of changedFiles) {