Hire me
Pooyan Razian

Clean up years of GitHub Actions runs automatically

Clean up years of GitHub Actions runs automatically
Published: July 16, 2026

Every workflow run stays in your Actions history forever, unless you clean it up yourself. After a year or two of CI, that history turns into thousands of runs nobody will ever open again. Scrolling through them to find anything useful becomes painful.

That is why I built Prune Old GitHub Actions Runs, a GitHub Action that deletes workflow runs older than a number of days you choose, on a schedule.

Get it on GitHub Marketplace · Source on GitHub

What it does

You give it a token and a number of days. Anything older than that gets deleted. You can also tell it to always keep the N most recent runs, regardless of age, so a workflow you rarely trigger does not lose its entire history. A dry-run mode lists what it would delete without deleting anything, which is worth running once before you trust it with the real thing.

Deletion is permanent and cannot be undone, so start with dry-run.

Inputs

InputRequiredDefaultDescription
tokenYes-GitHub token for authentication (use ${{ secrets.GITHUB_TOKEN }})
days-agoYes-number of days to look back when identifying old runs
dry-runNofalsewhen true, lists runs without deleting them
keep-latestNo0preserves the most recent N runs; 0 disables this

Example workflow

Save this as a scheduled workflow, for example .github/workflows/prune-old-actions.yml. Test with dry-run first:

on:
  schedule:
    - cron: '0 0 * * *'

permissions:
  actions: write

jobs:
  prune-old-actions:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: yanovian/prune-old-actions@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          days-ago: 30
          dry-run: true
          keep-latest: 5

Once you have checked the dry-run output and it deletes what you expect, drop dry-run (or set it to false) and let it run for real on the same schedule.

Permissions and tokens

Deleting workflow runs needs a token with write access to the Actions scope. The default GITHUB_TOKEN works if your workflow grants actions: write; a scoped personal access token or a GitHub App token are the more locked-down alternatives if you would rather not give the default token that reach.

Why it matters

The goal is simple: keep your Actions history relevant and your repository light, without spending time deleting runs by hand every few months. Set the retention window once, run it on a schedule, and forget about it.

If you liked the article, feel free to share it with your friends, family, or colleagues. You can also follow me on Medium or LinkedIn.

Copyright & Disclaimer

  • All content provided on this article is for informational and educational purposes only. The author makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site.
  • All the content is copyrighted, except the assets and content I have referenced to other people's work, and may not be reproduced on other websites, blogs, or social media. You are not allowed to reproduce, summarize to create derivative work, or use any content from this website under your name. This includes creating a similar article or summary based on AI/GenAI. For educational purposes, you may refer to parts of the content, and only refer, but you must provide a link back to the original article on this website. This is allowed only if your content is less than 10% similar to the original article.
  • While every care has been taken to ensure the accuracy of the content of this website, I make no representation as to the accuracy, correctness, or fitness for any purpose of the site content, nor do I accept any liability for loss or damage (including consequential loss or damage), however, caused, which may be incurred by any person or organization from reliance on or use of information on this site.
  • The contents of this article should not be construed as legal advice.
  • Opinions are my own and not the views of my employer.
  • English is not my mother-tongue language, so even though I try my best to express myself correctly, there might be a chance of miscommunication.
  • Links or references to other websites, including the use of information from 3rd-parties, are provided for the benefit of people who use this website. I am not responsible for the accuracy of the content on the websites that I have put a link to and I do not endorse any of those organizations or their contents.
  • If you have any queries or if you believe any information on this article is inaccurate, or if you think any of the assets used in this article are in violation of copyright, please contact me and let me know.

Clean up years of GitHub Actions runs automatically

Clean up years of GitHub Actions runs automatically
Published: July 16, 2026

Every workflow run stays in your Actions history forever, unless you clean it up yourself. After a year or two of CI, that history turns into thousands of runs nobody will ever open again. Scrolling through them to find anything useful becomes painful.

That is why I built Prune Old GitHub Actions Runs, a GitHub Action that deletes workflow runs older than a number of days you choose, on a schedule.

Get it on GitHub Marketplace · Source on GitHub

What it does

You give it a token and a number of days. Anything older than that gets deleted. You can also tell it to always keep the N most recent runs, regardless of age, so a workflow you rarely trigger does not lose its entire history. A dry-run mode lists what it would delete without deleting anything, which is worth running once before you trust it with the real thing.

Deletion is permanent and cannot be undone, so start with dry-run.

Inputs

InputRequiredDefaultDescription
tokenYes-GitHub token for authentication (use ${{ secrets.GITHUB_TOKEN }})
days-agoYes-number of days to look back when identifying old runs
dry-runNofalsewhen true, lists runs without deleting them
keep-latestNo0preserves the most recent N runs; 0 disables this

Example workflow

Save this as a scheduled workflow, for example .github/workflows/prune-old-actions.yml. Test with dry-run first:

on:
  schedule:
    - cron: '0 0 * * *'

permissions:
  actions: write

jobs:
  prune-old-actions:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: yanovian/prune-old-actions@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          days-ago: 30
          dry-run: true
          keep-latest: 5

Once you have checked the dry-run output and it deletes what you expect, drop dry-run (or set it to false) and let it run for real on the same schedule.

Permissions and tokens

Deleting workflow runs needs a token with write access to the Actions scope. The default GITHUB_TOKEN works if your workflow grants actions: write; a scoped personal access token or a GitHub App token are the more locked-down alternatives if you would rather not give the default token that reach.

Why it matters

The goal is simple: keep your Actions history relevant and your repository light, without spending time deleting runs by hand every few months. Set the retention window once, run it on a schedule, and forget about it.

If you liked the article, feel free to share it with your friends, family, or colleagues. You can also follow me on Medium or LinkedIn.

Copyright & Disclaimer

  • All content provided on this article is for informational and educational purposes only. The author makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site.
  • All the content is copyrighted, except the assets and content I have referenced to other people's work, and may not be reproduced on other websites, blogs, or social media. You are not allowed to reproduce, summarize to create derivative work, or use any content from this website under your name. This includes creating a similar article or summary based on AI/GenAI. For educational purposes, you may refer to parts of the content, and only refer, but you must provide a link back to the original article on this website. This is allowed only if your content is less than 10% similar to the original article.
  • While every care has been taken to ensure the accuracy of the content of this website, I make no representation as to the accuracy, correctness, or fitness for any purpose of the site content, nor do I accept any liability for loss or damage (including consequential loss or damage), however, caused, which may be incurred by any person or organization from reliance on or use of information on this site.
  • The contents of this article should not be construed as legal advice.
  • Opinions are my own and not the views of my employer.
  • English is not my mother-tongue language, so even though I try my best to express myself correctly, there might be a chance of miscommunication.
  • Links or references to other websites, including the use of information from 3rd-parties, are provided for the benefit of people who use this website. I am not responsible for the accuracy of the content on the websites that I have put a link to and I do not endorse any of those organizations or their contents.
  • If you have any queries or if you believe any information on this article is inaccurate, or if you think any of the assets used in this article are in violation of copyright, please contact me and let me know.
Copyright © 2026 - pooyan.info