From 8cdd61a976263ca52e1d53580c4d421d5f518369 Mon Sep 17 00:00:00 2001 From: Adam Daley Date: Mon, 18 Dec 2023 00:47:49 +0000 Subject: [PATCH] Update Docker workflow to workaround upload action changes --- .github/workflows/docker-build-push.yml | 43 ++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 41f77e9..5b79252 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -108,7 +108,48 @@ jobs: digest="${{ steps.build.outputs.digest }}" touch "/tmp/digests/${digest#sha256:}" - - name: 'Upload Digest' + - name: 'Check if Digests Artifact Exists and Merge' + uses: actions/github-script@v7 + with: + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: owner, + repo: repo, + run_id: context.runId, + name: 'digests' + }); + + if (artifacts.data.total_count > 0) { + console.log('Digests artifact already uploaded - retrieving.'); + const digests = await github.rest.actions.downloadArtifact({ + owner, + repo, + artifact_id: artifacts.data.artifacts[0].id, + archive_format: 'zip' + }); + require('fs').writeFileSync('/tmp/digests.zip', Buffer.from(digests.data)); + require('child_process').execSync(`unzip -o /tmp/digests.zip -d /tmp/digests`); + + console.log('Deleting already uploaded digests artifact.') + const result = await github.rest.actions.deleteArtifact({ + owner: owner, + repo: repo, + artifact_id: artifacts.data.artifacts[0].id + }); + + if (result.status == 204) { + return; + } else { + core.setFailed('Error occured deleting existing digests artifact'); + } + } else { + return; + } + + - name: 'Upload Digests' uses: actions/upload-artifact@v4 with: name: digests