From c150f7805ba4faeeee8eea4a9a36f32bc74dd9be Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Tue, 16 Aug 2022 15:51:57 -0700 Subject: [PATCH] Truncate Docker image artifact at end of Docker CI workflow In the (private) zeek-security repo we currently hit the 2GB storage limit whenever CI runs happen multiple times in one day, because our Docker Github workflow preserves the output of the first job (the image build) for the second job (the cluster tests). For successful runs, there's no need for the Docker image to survive the CI run. (For failures, it might help to grab the image for local testing.) There's no Github-official way to delete an attachment within a workflow, so this simply truncates the artifact if the workflow succeeds. --- .github/workflows/docker.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 54f06a6875..12cb66df6b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -168,3 +168,16 @@ jobs: name: cluster-btest path: testing/external/zeek-testing-cluster/.tmp if-no-files-found: ignore + + # To save storage space, truncate the Docker image artifact + # when this run was successful. + - name: Truncate Docker image + run: | + truncate -s0 ${{ env.IMAGE_FILE }} + + - name: Store truncated image artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.IMAGE_NAME }} + path: ${{ env.IMAGE_FILE }} + retention-days: 1