Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh/vmtests: truncate artifacts if run was successful
There does not seem to be an easy way to delete artifacts of the existing run (see details below). Instead, this patch truncates the build artifact so at least we do not waste space. I tried the following: - name: Delete artifacts uses: actions/github-script@v3 with: github-token: ${{ github.token }} script: | const {GITHUB_RUN_ID, GITHUB_REPOSITORY} = process.env const artifactsURL = `/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts` console.log(`Deleting artifacs from ${artifactsURL}`) const response = await github.request(`GET ${artifactsURL}`) console.log(response.data) for (artifact of response.data.artifacts) { console.log(`Deleting artifact with name=${artifact.name}, id=${artifact.id}`) const deleteResponse = await github.request(`DELETE /repos/${repo}/actions/artifacts/${artifact.id}`) } But it did not work, because the GITHUB_RUN_ID does not seem to be available over the REST API until after the action is finished. The logs from my action printed: Deleting artifacs from /repos/cilium/tetragon/actions/runs/2817658181/artifacts ... { total_count: 0, artifacts: [] } But if I curl the above URL after the action, I get: { "total_count": 1, "artifacts": [ { "id": 322874447, "node_id": "MDg6QXJ0aWZhY3QzMjI4NzQ0NDc=", "name": "tetragon-build", "size_in_bytes": 6, "url": "https://api.github.com/repos/cilium/tetragon/actions/artifacts/322874447", "archive_download_url": "https://api.github.com/repos/cilium/tetragon/actions/artifacts/322874447/zip", "expired": false, "created_at": "2022-08-08T11:50:54Z", "updated_at": "2022-08-08T11:50:54Z", "expires_at": "2022-08-13T11:49:30Z", "workflow_run": { "id": 2817658181, "repository_id": 473137633, "head_repository_id": 473137633, "head_branch": "pr/kkourt/lvhtest", "head_sha": "ea22990af2283c38aac92f7e6febacabf3786280" } } ] } For (even) more context, see: actions/upload-artifact#5 Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
- Loading branch information