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

[feat req] Allow retention-days to be 0 #290

Open
kolpav opened this issue Jan 31, 2022 · 11 comments
Open

[feat req] Allow retention-days to be 0 #290

kolpav opened this issue Jan 31, 2022 · 11 comments
Labels
enhancement New feature or request

Comments

@kolpav
Copy link

kolpav commented Jan 31, 2022

What would you like to be added?

Allow retention-days to be 0 meaning do not store artifacts after workflow run.

Why is this needed?


These solutions might be proposed but actually doesn't solve the problem with few points why I think they don't.

Use UI

  • You might not have permissions to delete artifacts
  • You have to go through all workflow runs without indication if it contains artifact or not
  • You have to delete all artifacts one by one manually

Use API

  • Seems like an overkill for something I would argue should be native functionality
  • You need to rely on API which might become obsolete or stop working

Use action from marketplace

  • I think this should be native functionality
  • You need to choose "right" action which might become unmaintained

This issue is duplicate

  • I think I mentioned problems people are actually having by going through issues and threads on other sites
  • I have found no suitable solution in other issues
  • I think other relevant issues are worded poorly and making it seem they don't know how to delete some specific artifact once when in fact after reading into their problem more they actually want what I described here
@kolpav kolpav added the enhancement New feature or request label Jan 31, 2022
@praenubilus
Copy link

Can't believe it, the original issue was created 3 years ago and it still has no official action

@kolpav
Copy link
Author

kolpav commented Feb 4, 2022

@praenubilus I share your disbelief. To be completely honest I wouldn't be surprised if this is "by design" or fix would be very hard to approve in github's chain of command because people would stop polluting their storage with useless artifacts just to share data between jobs (build -> test -> deploy) it would decrease amount of people

  • upgrading to pro to increase their storage limit
  • entering their payment information which makes them much easier to sell future products to
  • maxing their monthly spending limit

but lets not jump to conclusions and wait for feedback.

@praenubilus
Copy link

@kolpav I hope the day it comes out I am still alive

@Koushikphy
Copy link

I was releasing nodejs application binary with GitHub workflow for different os and architecture. In the initial stage, I was testing different workflow patterns and quickly hit the quota limit. I don't really need the artifacts after the workflow is run and the artifacts are released. It's disappointing to see that it does not have the delete option when the workflow si complete.

@yanniboi
Copy link

Currently we have to manually delete the artifacts after every run. This would be so much easier if we could just set them to be removed after the run automatically.

@laureanray
Copy link

This seems like it should've been implemented in the first place. I've been constantly reaching artifact storage quota errors. 😞

@DPatrickBoyd
Copy link

DPatrickBoyd commented Jan 6, 2023

here is an example that I just got to work for deletion after a run is done. This is triggered from the workflow that made the artifact
secrets.GH_REPO_ACCESS_PAT is a PAT that I made and gave it the ability read repos and org stuff as well, not sure how important the scope is.

name: Test

on:
  workflow_run:
    branches: [main]
    workflows: [nonprod,prod,test]
    types:
      - completed
jobs:
  on-success:
    runs-on: ubuntu-latest
    name: Delete artifact
    if: github.event.workflow_run.head_branch == 'main' # feel free to take this out if you don't need it
    steps:
      - id: get-id
        run: | # grab the id of the artifact we just created
          echo "ARTIFACT_ID=$(gh api -H 'Accept: application/vnd.github+json'   ${{github.event.workflow_run.artifacts_url}} --jq .artifacts[].id)" >> $GITHUB_ENV
        env:
          GITHUB_TOKEN: ${{ secrets.GH_REPO_ACCESS_PAT }}
      - run: |
          echo "artifact id is ${{ env.ARTIFACT_ID}}"
          echo "run url is ${{github.event.workflow_run.artifacts_url}}"
      - id: delete-artifact
        run: | # https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#delete-an-artifact
          gh api --method DELETE -H 'Accept: application/vnd.github+json' /repos/${{github.repository}}/actions/artifacts/${{env.ARTIFACT_ID}}
        env:
          GITHUB_TOKEN: ${{ secrets.GH_REPO_ACCESS_PAT }}
  on-failure:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'failure' }}
    steps:
      - run: echo 'The triggering workflow failed'

@kolpav
Copy link
Author

kolpav commented Jan 7, 2023

@DPatrickBoyd I linked your comment if you don't mind :) https://github.com/kolpav/purge-artifacts-action/blob/master/README.md

@DPatrickBoyd
Copy link

@DPatrickBoyd I linked your comment if you don't mind :) https://github.com/kolpav/purge-artifacts-action/blob/master/README.md

not a problem! glad to help anyone else out, I have been saved so many times in the past by a random github comment so trying to return the favor

@zumbiepig
Copy link

bump

@brmb
Copy link

brmb commented Oct 12, 2024

bump!

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

8 participants