Skip to content

stefanluptak/delete-old-pr-artifacts

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Delete old pull request artifacts (GitHub Action)

GitHub Action to delete all workflow artifacts for a branch

Motivation

Artifacts generated by pull-requests can quickly use all the storage you paid for. Usually, when the PR is merged or closed, artifacts belonging to that pull-request are no longer needed. To delete them, use this GitHub Action.

Usage

When closing pull request

name: PR cleanup

on:
  pull_request:
    types: [closed]

jobs:
  delete_pr_artifacts:
    runs-on: ubuntu-latest
    steps:
      - uses: stefanluptak/delete-old-pr-artifacts@v1
        with:
          workflow_filename: ci.yaml

When synchronizing pull request

If you want to delete previous artifacts for active PR, just use event type synchronize instead of closed. Remember to call this action before building fresh new artifact to not delete it too.

Parameters

Parameter Description Required Default
workflow_filename Filename of the workflow that generated artifacts you want to delete
github_token GitHub token used to authenticate you GitHub API calls github.token
github_repo GitHub repository you want to delete the artifact in github.repository
git_branch Git branch of the pull request github.head_ref
debug Set to true if you want to see some debugging output. false
dry_run Set to true if you don't want to really delete the artifact, but only to see the what would be deleted. false

Disclaimer

This is my first GitHub Action. Feel free to contribute, ask or give me advice on how to improve it. Thanks. :-)

About

GitHub Action to delete all workflow artifacts for a branch

Resources

License

Stars

Watchers

Forks

Packages

No packages published