From b59d8c6a6c5c6c6437954f470d963c0b20ea7415 Mon Sep 17 00:00:00 2001 From: Robbie Heywood <83235170+robbie-unlikelyai@users.noreply.github.com> Date: Mon, 13 Feb 2023 15:27:38 +0000 Subject: [PATCH] Add pagination to appropriate listWorkflowRunArtifacts call (#225) --- .github/workflows/download.yml | 30 ++++++++++++++++++++++++++++++ main.js | 6 +++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/download.yml b/.github/workflows/download.yml index 20d7a27b..4e2cd467 100644 --- a/.github/workflows/download.yml +++ b/.github/workflows/download.yml @@ -140,3 +140,33 @@ jobs: dry_run: true - name: Test run: test ${{ steps.download.outputs.dry_run }} == false + download-with-check-artifacts: + runs-on: ubuntu-latest + needs: wait + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Download + uses: ./ + with: + workflow: upload.yml + name: artifact + path: artifact + check_artifacts: true + - name: Test + run: cat artifact/sha | grep $GITHUB_SHA + download-with-search-artifacts: + runs-on: ubuntu-latest + needs: wait + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Download + uses: ./ + with: + workflow: upload.yml + name: artifact + path: artifact + search_artifacts: true + - name: Test + run: cat artifact/sha | grep $GITHUB_SHA diff --git a/main.js b/main.js index a14c8903..8689ecd2 100644 --- a/main.js +++ b/main.js @@ -122,16 +122,16 @@ async function main() { continue } if (checkArtifacts || searchArtifacts) { - let artifacts = await client.rest.actions.listWorkflowRunArtifacts({ + let artifacts = await client.paginate(client.rest.actions.listWorkflowRunArtifacts, { owner: owner, repo: repo, run_id: run.id, }) - if (artifacts.data.artifacts.length == 0) { + if (!artifacts || artifacts.length == 0) { continue } if (searchArtifacts) { - const artifact = artifacts.data.artifacts.find((artifact) => { + const artifact = artifacts.find((artifact) => { return artifact.name == name }) if (!artifact) {