A simple Python script to delete all GitHub Actions workflow runs from a repository using the GitHub API. Ideal for cleaning up old workflows, especially for repositories with frequent deploys.
Note: Is not committed to GitHub or stored in public files.
- Fetches workflow runs from GitHub Actions API.
- Deletes all workflow runs in batches (100 per page).
- Logs success and failure status for each run deletion.
- Easy to configure with your GitHub username, repository, and token.
- Python 3.6+
requests
module (Install using:pip install requests
)
-
Clone this repository
git clone https://github.com/AdityaLF/Delete-GH-Workflow-Runs.git cd Delete-GH-Workflow-Runs
-
Generate your GitHub Personal Access Token (PAT):
-
Go to GitHub Token Settings.
-
Click on "Generate new token".
-
Provide a name for the token ("delworkflows-script").
-
Select the required scopes:
-
repo: needed for repository actions.
-
workflow: needed to delete workflows.
-
-
Click Generate token.
-
Copy the token (you wonβt be able to see it again, so store it securely).
-
-
Edit the configuration section at the top of the script:
owner = 'your-username' # Replace with your GitHub username repo = 'your-repository' # Replace with your GitHub repository name token = 'your-github-token' # Replace with your GitHub Personal Access Token (PAT)
-
Run the script:
python delworkflows.py
- GitHub: @AdityaLF
- Discord: @05.07am
- Support Me: ko-fi.com/adityalf
This project is licensed under the MIT License.