GeekyEggo / delete-artifact

A GitHub Action to deletes artifacts within the workflow run.
MIT License
192 stars 51 forks source link

Unable to delete artifacts uploaded by `actions/upload-artifact@v4` #14

Closed muzimuzhi closed 10 months ago

muzimuzhi commented 10 months ago

An example workflow: https://github.com/muzimuzhi/hello-github-actions/actions/runs/7256001370

More comparisons can be found in https://github.com/muzimuzhi/hello-github-actions/pull/24. It seems changes more than a naive package upgrading are needed (I'm not a front-end developer). Also the listArtifacts() function from @actions/artifact might be helpful.

Several breaking changes were introduced in actions/upload-artifact@v4, see

GeekyEggo commented 10 months ago

Hi @muzimuzhi, thanks for bringing this to my attention.

I've prepared a pull request (#17) that introduces support for actions/upload-artifact@v4 by utilizing the GitHub REST API; as a result of this change is the requirement of a PAT with read and write access when running the action.

muzimuzhi commented 10 months ago

Thanks! I confirm with https://github.com/GeekyEggo/delete-artifact/pull/17 now GeekyEggo/delete-artifact@main works as expected. 🎉

Looking forward to a v4.0.0 release.

BTW then two example.yml may be needed, one for v2 and one for v4.

GeekyEggo commented 10 months ago

geekyeggo/delete-artifact@v4 has been tagged and released, and the examples have been updated. 🎉

If you experience any problems, please let me know. Happy holidays.

rolfkoizumi commented 8 months ago

I have just upgraded our upload/download actions from @v3 to @v4 - and also tried updating this action to @v4 Out of the box, we are getting this error:

image

Exactly the same setup with all actions@v3 worked. One thing though - the actions/upload-artifact@v4 and geekyeggo/delete-artifact@v4 are in two different subsequent jobs.

I have tried:

I have then tried deleting the artifact inside the same job in a subsequent step instead of in the next job. This worked.

This is the upload-step in one job: image And this is the delete-step in a subsequent job: image I have checked that the name is exactly the same in the upload and delete step.

I'd greatly appreciate any ideas to what I'm doing wrong.

muzimuzhi commented 8 months ago

@rolfboom Seems like related to workflow permissions, see a similar post https://github.com/orgs/community/discussions/60820.

BTW, better to raise a new issue.

Bouni commented 8 months ago

For me the solution was to add actions: write


deploy:
  name: "Deploy"
  runs-on: ubuntu-20.04
  permissions:
      actions: write
  steps:
     - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
      # delete-artifact
      - name: Clean
        uses: geekyeggo/delete-artifact@v4
        with:
          name: github-pages