How to remove github actions artifact produced during runtime

4.3k Views Asked by At

During workflow execution, I produce several artifacts but after a successful build I no longer need them and I want to clean that up as I only need them temporarily.

- name: Make artifact available to use
        uses: actions/upload-artifact@v2
        with:
          name: setup
          path: setup.yml

As a part of a different job I need artifacts so I also have

- name: Download yaml file
        uses: actions/download-artifact@v2
        with:
          name: setup

How can I add a step in the workflow (in my case, the last step) that's gonna remove these artifacts that were produced during runtime?

2

There are 2 best solutions below

0
On

As part of a python API for accessing GitHub. One of the examples provides a tool for waxy repository artifact build-up. Demo: https://youtu.be/lS37uCKELNM

2
On

There are delete artifact actions on the marketplace that could help you with that.

Example with this one:

steps:
- uses: actions/checkout@v3

- run: echo hello > world.txt

- name: Make artifact available to use
  uses: actions/upload-artifact@v2
  with:
    name: setup
    path: world.txt

# delete-artifact
- uses: geekyeggo/delete-artifact@v1
  with:
    name: setup

I made a workflow run example here if you want to have a look.