Delete artifacts

I was reading the discution between @mscoutermarsh and @paul-sachs and got a little bit confused in the term “Job”. The docs says “A workflow is a configurable automated process made up of one or more jobs.” so I though that maybe i could use @paul-sachs 's script to delete the artificact produced by Job A in Job B. I did not succeed.

Improving @mscoutermarsh 's answer i could say that:
The runner doesn’t “record” the Artifacts until the workflow run completes. Once the workflow run is completed, then they are available in the API.

I also agree with @paul-sachs  that the artifact could be availlable in the API by the end of the Job that creates/uploads it, in order to delete it by the end of the workflow run

I have made a gist that automatically fetches all repositories of the given organization and deletes all artifacts but the amount that is given. Default is set to two. You can find the gist here: https://gist.github.com/Sef1995/36415c0da0db6f9424183fa455569f4c

5 Likes

Hi, is a retention setting coming along?

This is ridiculous. Never had this issue with any other CI solution.

I am sharing data between jobs of same workflow which generates a lot of artifacts which I can’t be bothered to delete manually. I wrote action for that which I tought might be useful for others so I open sourced it

https://github.com/marketplace/actions/purge-artifacts

3 Likes

Here’s what works for me to delete no longer needed artifacts right at the end of the workflow run in which they have been created. I use it to delete temporary artifacts created by matrix build jobs after they have been uploaded to a github release.

https://github.com/marketplace/actions/delete-run-artifacts

Our team has created an Action to periodically clean up old artifacts:

https://github.com/c-hive/gha-remove-artifacts

It also supports keeping tagged (release) artifacts.

There is now a **delete-artifact** action available on the marketplace. It is currently a pre-release as it is using a preview API, however it is capable of deleting artifacts created within the same eworkflow. This can be particularly useful when sharing temporary artifacts amongst jobs.

https://github.com/marketplace/actions/delete-artifact

is there a way to delete all artifacts from the UI in the organization’s billing page? Or at least show from what repository the artifact belongs to and the artifacts themselves? I find it frustrating that I can’t see what artifact is consuming space. I have to go through each repository just to find it which is tedious.

Edit: I’ve also ran @sef1995’s script on the org in question but it found no packages in that org. Yet in Billing > Storage for Actions and Packages it reports that I’m consuming 1.03GB.

You can now change artifact and log retention duration either through Actions Settings tab or via YAML. You can learn more about this feature here. Feedback is welcome!