yanovation/delete-old-actions
Deletes old Github Actions
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
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: 30Or you can test with dry-run option:
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):
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: 5Options
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.
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.
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):
...
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: 30You can read more about it here.
Also, another option is to create a Personal Access Token (PAT).
Make sure to give the token the least needed access.