upload-artifact
upload-artifact copied to clipboard
[feat req] Allow `retention-days` to be `0`
What would you like to be added?
Allow retention-days
to be 0
meaning do not store artifacts after workflow run.
Why is this needed?
- You have no use of artifacts after workflow run
- You don't want them to take up space for minimum period of 24h
- 24h duration seems arbitrary chosen (edit: It might be limitation of backing storage being used "the minimum retention interval for a time-based retention policy is one day...")
- 24h is too long to not hit your CI storage limit
- Available storage calculation is buggy or takes a while to update after hitting storage limit and deleting artifacts
- https://github.com/actions/upload-artifact/issues/5
- https://github.com/actions/upload-artifact/issues/9
- https://github.com/actions/upload-artifact/issues/301
- https://github.com/actions/upload-artifact/issues/307
- https://github.com/actions/upload-artifact/issues/148
- https://github.com/actions/upload-artifact/issues/59
- https://github.com/actions/upload-artifact/issues/45
- https://github.com/actions/toolkit/issues/380
These solutions might be proposed but actually doesn't solve the problem with few points why I think they don't.
Use UI
- You might not have permissions to delete artifacts
- You have to go through all workflow runs without indication if it contains artifact or not
- You have to delete all artifacts one by one manually
Use API
- Seems like an overkill for something I would argue should be native functionality
- You need to rely on API which might become obsolete or stop working
Use action from marketplace
- I think this should be native functionality
- You need to choose "right" action which might become unmaintained
This issue is duplicate
- I think I mentioned problems people are actually having by going through issues and threads on other sites
- I have found no suitable solution in other issues
- I think other relevant issues are worded poorly and making it seem they don't know how to delete some specific artifact once when in fact after reading into their problem more they actually want what I described here
Can't believe it, the original issue was created 3 years ago and it still has no official action
@praenubilus I share your disbelief. To be completely honest I wouldn't be surprised if this is "by design" or fix would be very hard to approve in github's chain of command because people would stop polluting their storage with useless artifacts just to share data between jobs (build -> test -> deploy) it would decrease amount of people
- upgrading to pro to increase their storage limit
- entering their payment information which makes them much easier to sell future products to
- maxing their monthly spending limit
but lets not jump to conclusions and wait for feedback.
@kolpav I hope the day it comes out I am still alive
I was releasing nodejs application binary with GitHub workflow for different os and architecture. In the initial stage, I was testing different workflow patterns and quickly hit the quota limit. I don't really need the artifacts after the workflow is run and the artifacts are released. It's disappointing to see that it does not have the delete option when the workflow si complete.
Currently we have to manually delete the artifacts after every run. This would be so much easier if we could just set them to be removed after the run automatically.
This seems like it should've been implemented in the first place. I've been constantly reaching artifact storage quota errors. 😞
here is an example that I just got to work for deletion after a run is done. This is triggered from the workflow that made the artifact secrets.GH_REPO_ACCESS_PAT is a PAT that I made and gave it the ability read repos and org stuff as well, not sure how important the scope is.
name: Test
on:
workflow_run:
branches: [main]
workflows: [nonprod,prod,test]
types:
- completed
jobs:
on-success:
runs-on: ubuntu-latest
name: Delete artifact
if: github.event.workflow_run.head_branch == 'main' # feel free to take this out if you don't need it
steps:
- id: get-id
run: | # grab the id of the artifact we just created
echo "ARTIFACT_ID=$(gh api -H 'Accept: application/vnd.github+json' ${{github.event.workflow_run.artifacts_url}} --jq .artifacts[].id)" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GH_REPO_ACCESS_PAT }}
- run: |
echo "artifact id is ${{ env.ARTIFACT_ID}}"
echo "run url is ${{github.event.workflow_run.artifacts_url}}"
- id: delete-artifact
run: | # https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#delete-an-artifact
gh api --method DELETE -H 'Accept: application/vnd.github+json' /repos/${{github.repository}}/actions/artifacts/${{env.ARTIFACT_ID}}
env:
GITHUB_TOKEN: ${{ secrets.GH_REPO_ACCESS_PAT }}
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
@DPatrickBoyd I linked your comment if you don't mind :) https://github.com/kolpav/purge-artifacts-action/blob/master/README.md
@DPatrickBoyd I linked your comment if you don't mind :) https://github.com/kolpav/purge-artifacts-action/blob/master/README.md
not a problem! glad to help anyone else out, I have been saved so many times in the past by a random github comment so trying to return the favor
bump