1

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?

hmdevno
  • 99
  • 5

2 Answers2

1

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.

GuiFalourd
  • 15,523
  • 8
  • 44
  • 71
  • Thanks. And this is great, but unfortunately not something I can use within my organization. – hmdevno Sep 08 '22 at 11:25
  • 1
    If you're worried about using an open source action inside your organization, you can create your own action or reusable workflow, consuming the Github API: `https://api.github.com/repos/OWNER/REPO/actions/artifacts/$id` ([example with a bash script doing it](https://gist.github.com/qwe321qwe321qwe321/efae4569576006624c34f23b2dd76a58) – GuiFalourd Sep 08 '22 at 11:36
0

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

Andrew
  • 2,530
  • 16
  • 9