Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Artifact Action #550

Open
Kamysek opened this issue Apr 2, 2024 · 1 comment
Open

Delete Artifact Action #550

Kamysek opened this issue Apr 2, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Kamysek
Copy link

Kamysek commented Apr 2, 2024

What would you like to be added?

Hello,

Could GitHub consider adding an official "Delete Artifact" action? This would complement the existing upload and download actions, streamlining artifact management in actions. It seems like a natural and beneficial enhancement to the platform.

Thank you for considering,
Josef

Why is this needed?

The v4 upload action's inability to append to an existing artifact across various jobs in a matrix complicates artifact management significantly. Users now find themselves in a convoluted cycle of uploading individual outputs as distinct artifacts, downloading these for merging, and re-uploading the merged file for a consolidated outcome. Since then the non consolidated outcome is not needed it would be nice to be able to delete it.

@Kamysek Kamysek added the enhancement New feature or request label Apr 2, 2024
@robherley
Copy link
Contributor

Since then the non consolidated outcome is not needed it would be nice to be able to delete it.

actions/upload-artifact/merge@v4 has a delete-merged option, see this example: https://github.com/actions/upload-artifact/tree/main/merge#deleting-artifacts-after-merge

Unfortunately I don't think we'll be investing in a separate delete artifact action anytime soon.

Here's an example of using github-script:

name: Delete Artifact Example
on:
  workflow_dispatch:

permissions:
  actions: write # required permission to delete artifact

jobs:
  upload-and-delete:
    runs-on: ubuntu-latest
    steps:
    - name: Create a File
      run: echo "hello world" > hello.txt
    - name: Upload Artifact
      id: artifact-upload
      uses: actions/upload-artifact@v4
      with:
        name: my-artifact
        path: hello.txt
    - name: Delete Artifact
      uses: actions/github-script@v7
      with:
        script: |
          github.rest.actions.deleteArtifact({
            owner: context.repo.owner,
            repo: context.repo.repo,
            artifact_id: ${{ steps.artifact-upload.outputs.artifact-id }}
          });
    - name: Upload Artifact (again)
      uses: actions/upload-artifact@v4
      with:
        name: my-artifact
        path: hello.txt

If you find a need to delete artifacts often, you can wrap the code in a composite action, reusable workflow, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants