GitHub Action to delete all workflow artifacts for a branch
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.
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.yamlIf 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.
| 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 |
This is my first GitHub Action. Feel free to contribute, ask or give me advice on how to improve it. Thanks. :-)