From 326e5649d3101a3a595b2ed6ffaa20b7aa7f12bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Sat, 11 May 2024 15:35:46 +0200 Subject: [PATCH 1/2] ci: updated to actions/upload-artifact v4 --- .github/workflows/comment.yml | 23 +++++++++++++---------- .github/workflows/nodejs.yml | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml index 6518c81c..18acaaf7 100644 --- a/.github/workflows/comment.yml +++ b/.github/workflows/comment.yml @@ -35,17 +35,20 @@ jobs: repo: context.repo.repo, run_id: ${{ github.event.workflow_run.id }}, }); - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == "screenshots" - })[0]; - var download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', + var matchingArtifacts = artifacts.data.artifacts.filter((artifact) => { + return artifact.name.startsWith("screenshots-"); }); - var fs = require('fs'); - fs.writeFileSync('${{github.workspace}}/screenshots.zip', Buffer.from(download.data)); + + for (const artifact of matchingArtifacts) { + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync(`${{github.workspace}}/${artifact.name}.zip`, Buffer.from(download.data)); + } - run: unzip -d screenshots screenshots.zip diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 038adcf3..5ede4f61 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -172,9 +172,9 @@ jobs: mv screenshots/*.png screenshots/dist/$aw_server/$aw_version - name: Upload screenshots if: ${{ success() || steps.e2e.conclusion == 'failure'}} - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4 with: - name: screenshots + name: screenshots-${{ matrix.aw-server }}-${{ matrix.aw-version }} path: screenshots/dist/* - name: Print server logs to console if: ${{ always() }} From 57c378bbc04215f3855c2023d0122b7d6b7b0d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Sat, 11 May 2024 15:42:02 +0200 Subject: [PATCH 2/2] ci: fixed unzipping multiple screenshot artifacts --- .github/workflows/comment.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml index 18acaaf7..f058d4e1 100644 --- a/.github/workflows/comment.yml +++ b/.github/workflows/comment.yml @@ -30,6 +30,8 @@ jobs: uses: actions/github-script@v7 with: script: | + var fs = require('fs'); + var child_process = require('child_process'); var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, @@ -46,12 +48,13 @@ jobs: artifact_id: artifact.id, archive_format: 'zip', }); - var fs = require('fs'); fs.writeFileSync(`${{github.workspace}}/${artifact.name}.zip`, Buffer.from(download.data)); + // Unzip the artifact + child_process.execSync(`unzip -d screenshots ${artifact.name}.zip`, {cwd: process.env.GITHUB_WORKSPACE}); + // Remove the zip file + fs.unlinkSync(`${{github.workspace}}/${artifact.name}.zip`); } - - run: unzip -d screenshots screenshots.zip - - name: Compose comment env: repo_token: ${{ secrets.GITHUB_TOKEN }}