https://github.com/yanovation/delete-old-actions
Deletes old Github Actions
https://github.com/yanovation/delete-old-actions
clean cleaner github github-actions history-management
Last synced: 5 months ago
JSON representation
Deletes old Github Actions
- Host: GitHub
- URL: https://github.com/yanovation/delete-old-actions
- Owner: yanovation
- License: apache-2.0
- Created: 2025-03-01T09:53:44.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-07-23T03:53:58.000Z (7 months ago)
- Last Synced: 2025-07-23T05:25:49.742Z (6 months ago)
- Topics: clean, cleaner, github, github-actions, history-management
- Language: TypeScript
- Homepage: https://pooyan.info
- Size: 643 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
[](https://github.com/yanovation/delete-old-actions/blob/main/LICENSE.md)
[](https://github.com/yanovation/delete-old-actions/commits/main)
[](https://github.com/yanovation/delete-old-actions/graphs/contributors)
# About
Removes old GitHub Actions runs to keep your repository clean.
You are advised to run this action with the dry-run option first to see what will be deleted.
When you are ready to use this, you can schedule it to check periodically.
**WARNING: Deletion cannot be undone. Use at your own risk.**
## Usage
```yaml
on:
schedule:
- cron: '0 0 * * *' # Specify your own schedule
jobs:
delete-old-actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: yanovation/delete-old-actions@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
days-ago: 30
```
Or you can test with dry-run option:
```yaml
on:
schedule:
- cron: '0 0 * * *'
jobs:
delete-old-actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: yanovation/delete-old-actions@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
days-ago: 30
dry-run: true
```
You can also keep the last N runs (N = 5 in this example):
```yaml
on:
schedule:
- cron: '0 0 * * *'
jobs:
delete-old-actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: yanovation/delete-old-actions@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
days-ago: 30
dry-run: true
keep-latest: 5
```
## Options
* `token`: The GitHub token to use for authentication. (**required**)
* `days-ago`: The number of days ago to delete the runs. (**required**)
* `dry-run`: If set to true, the Action will only list the runs to be deleted without actually deleting them. (**optional**,
default: false, meaning it will delete the runs)
* `keep-latest`: The number of latest runs to keep. (**optional**, default: 0, meaning this option is disabled)
For the token, you can just use the `{{ secrets.GITHUB_TOKEN }}` which is a default secret that GitHub provides to each
run. You can read more about
it [here](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication).
## Token permissions
If you want to use the default `${{ secrets.GITHUB_TOKEN }}`, you should give it a write permissions either on the
repository or organization level:

You can read more about it [here](https://docs.github.com/en/actions/security-guides/automatic-token-authentication).
This is **the easiest way**, especially if you have multiple repositories within multiple organizations and have access to
update this setting, but **gives too much access to the token**.
Alternatively, you can authenticate with a GitHub App (needs more setup):
```yaml
...
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: yanovation/delete-old-actions@v1
with:
token: ${{ steps.generate-token.outputs.token }}
days-ago: 30
```
You can read more about it [here](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow#authenticating-with-a-github-app).
Also, another option is to create a [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
Make sure to give the token the least needed access.
## Other docs
- [How to release](./_docs/release.md)
- [How to contribute](./CONTRIBUTING.md)
- [License](./LICENSE.md)
- [Change log](./CHANGELOG.md)
## Articles (to learn more about it)
- [Automatically delete old GitHub Actions runs](https://pooyan.info/articles/delete-old-github-actions-runs)