Upload-artifact: How to remove uploaded artifact?

Created on 21 Aug 2019  路  37Comments  路  Source: actions/upload-artifact

It is possible to remove an uploaded artifact?

enhancement

Most helpful comment

We need this feature because there is a 1GB limits on artifacts and we do not need the older ones.

All 37 comments

ping...

@madhurig for artifact questions

Currently there is no experience to remove uploaded artifacts. Is there a scenario you have that you would need this feature for or are you looking to remove an artifact accidentally uploaded?

Is there a scenario you have that you would need this feature for or are you looking to remove an artifact accidentally uploaded?

We expect to use GitHub Action and artifacts to provide 'nightly builds' without having to deal with GitHub Releases. I.e., we currently build a tarball and run tests with it, as a regular CI job. We expect to reuse the same tarball, instead of triggering all the release procedure (which is meant for tagged commits/releases).

In the situations when a tarball passes the tests but it is not valid because of any other reason, we want to remove the artifacts. This would allow us to tell users: you can pick the latest successful (green) run which contains artifacts, and ensure that the first file they download will work.

BTW, can you please have a look at #3?

Is there a scenario you have that you would need this feature for or are you looking to remove an artifact accidentally uploaded?

@madhurig I was using artifacts to pass docker images and some gcloud configs between jobs so that I don't have to re-auth with the gcloud sdk in different jobs. It might not be the most optimised way but I was exploring that idea a few weeks ago. It will be good if we can remove these artifacts at the end of the jobs to clean up.

@williamli - Thanks for elaborating. We will evaluate this feature.

We need this feature because there is a 1GB limits on artifacts and we do not need the older ones.

Is there some API to remove uploaded artifacts instead?
I would like to set up a github action cronjob to remove artifacts older than 1 month.

As far as I can tell there鈥檚 not only no API, but no manual removal route either. This is because, as noted above, they鈥檇 not been evaluated the needed user experience. For instance, while they could release an api, would an expiration policy work better? Or maybe something else? Perhaps a totally different tool is needed, eg a cleaner way to pass messages or files from one job to another.
Hence they are on the discovery phase for this and need our input on how and why we are using artifacts.

ATM my use case is that of inter job communications. Later I might use artifacts to hold build or test results for review.

Thanx @kf6kjg
For me I guess expiration policy would work, too.

I mean, not having a way to remove artifacts and at the same time billing for over-filled storage is a contradiction to me.

Btw my usecase: we integrated cypress with videos stored as artifacts - there is no need to have them for longer than few days.

Hi all, we're working on an API for deleting an artifact. Thanks for sharing your use cases 鉂わ笍.

I don't have a timeline yet that I can share on when it will be available.

There is a workaround, you could create an empty directory and upload a new artifact of the same name with path of the empty directory.

      - name: create empty directory
        run: |
          mkdir empty.d

      - name: empty dist archive
        uses: actions/upload-artifact@v1
        with:
          name: dist
          path: empty.d

Example: https://github.com/rtoken-project/rdai/blob/master/.github/workflows/cd.yml

Update: it seems github changed some logic, the workround is no longer working!!

Unless there's special server code for that case, a zip file of an empty directory still occupies ~80kB of space. Certainly less than the zip it replaced, but continual growth is still growth even if you manage to reduce the rate.
All that said, while I don't consider it a workaround, @hellwolf you've got a clever technique to reduce the impact. Thanks! :D

I could not manage to make @hellwolf 's workaround to work:

After uploading the empty folder with the same name as an artifact I could download the original artifact from action's UI, and the size displayed matched with the original file size as if nothing changed.

When I added an empty file to empty.d with the name of the original file, I could no longer access the original file as if it was replaced by the empty one, but the UI still displayed the original file size.

Even though I could not access the artifact in the last case, I'm not sure it's actually replaced with the empty file behind the scenes.

@dodie yes, it seems github changed some logic, the workround is no longer working!!

Actions engineer here 馃憢 There's now the possibility to delete the artifact in the UI. You'll see a trash can icon if you have permissions to write in the repository contents.

Screen Shot 2020-01-07 at 16 08 06

@gimenete not sure if this is intentional or not but there's no confirmation dialog on mobile like there is on desktop.

@dodie @hellwolf @dentarg The workaround should no longer work, we recently made some backend changes to our artifacts service. The recent changes to the download experience were part of a broader backend update but not directly responsible for the workaroud no longer working.

Recommend to use the new UI now 馃榾 That will completely delete the artifact and there won't be any empty directories.

I've updated the README in this repo with some information about deleting an artifact from the UI with a new screenshot. A DELETE API for artifacts is in development so there will be more ways to delete an artifact down the road. Going to close this issue now that there is at least one way to delete an artifact.

is it possible to remove the artifacts from an action / api?

is it possible to remove the artifacts from an action / api?

A DELETE API for artifacts is in development so there will be more ways to delete an artifact down the road.

And there was joyful singing! Now to get that incorporated into the actions that need it! :D

https://developer.github.com/v3/actions/artifacts/#delete-an-artifact

How we can use it in GitHub workflow .

now that there's an api (thanks for that!) an official actions/upload-artifact@v1 action would be awesome ;-)

now that there's an api (thanks for that!) an official actions/upload-artifact@v1 action would be awesome ;-)

Is there any open ticket for this?

now that there's an api (thanks for that!) an official actions/upload-artifact@v1 action would be awesome ;-)

Is there any open ticket for this?

I don't think so...

If anyone wants to have simple expiration policy for their artifacts I wrote github action just for that. Its enough for my usecase if there is some functionality you would like to see let me know in issue. https://github.com/marketplace/actions/purge-artifacts

This just started killing our cicd. I tried @kolpav purge library, and I'm still getting the error.

I'm building an app that takes about 5 minutes to build a 130mb, which it needs to upload as an artifact, so it can be downloaded by 3+ test servers to run parellel tests. We hit our artifact limit pretty quickly, and I don't know how to make space.

I've manually deleted a bunch of artifacts from previous runs, and I ran @kolpav's action before doing my upload. I'm still getting the error.

This is a blocker. Can anyone help?

I'm seeing https://developer.github.com/v3/actions/artifacts/#delete-an-artifact above. Anyone have an example of that being used in a github action?

@craig-dae What do you see in https://github.com/settings/billing "Storage for Actions and Packages" section?

Nothing because I don't own the account. I think your action worked though, but the effect was delayed.

That's the other thing. GitHub can't expect the developer who is building the pipeline to have full access to the account, and insight onto that page. Generally, it's the CTO or someone one level below the CTO with that access. There needs to be a way for someone without billing-access to view the artifacts/actions information. I just found out yesterday that we have spent 72% of our GitHub actions for the month in the first two weeks of using them.

Anyway, I think we're back in action. I think that your action works, but I think there is a delay between clearing out artifacts, and GitHub letting you use the reclaimed space. About 2 hours after I ran the action, pipelines uploading artifacts started working again.

@craig-dae yes, I鈥檓 also seeing a short delay between deleting artifacts and the usage/quota display in the account settings being updated.

@craig-dae I'm seeing https://developer.github.com/v3/actions/artifacts/#delete-an-artifact above. Anyone have an example of that being used in a github action?

@kolpav : If anyone wants to have simple expiration policy

thanks, that's useful!

I have another example for a different usecase (delete no longer needed artifacts at the end of the workflow run in which they have been created):
https://github.com/marketplace/actions/delete-run-artifacts

(I use it to delete temporary artifacts created by matrix build jobs after they have been uploaded to a github release and S3 bucket).

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.

I'm using upload-artifact to share intermediary work between jobs. Idea taken from here: https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts

However, the intermediary work is junk on its own. It would be nice if I didn't have to manually go into the history and click delete all the time.

Maybe there should be a actions/delete-artifact. :thinking:

The effect delay wasted me a good 30min as I was not sure if the action by @kolpav was not functioning or something else is going on...

Was this page helpful?
0 / 5 - 0 ratings