Reputation: 16865
So I tried to put a docker-compose.yml
file in the .github/workflows
directory, of course it tried to pick that up and run it... which didn't work. However now this always shows up as a workflow, is there any way to delete it?
Upvotes: 6
Views: 4600
Reputation: 2029
To delete a particular workflow on your Actions page, you need to delete all runs which belong to this workflow. Otherwise, it persists even if you have deleted the YAML file that had triggered it.
If you have just a couple of runs in a particular action, it's easier to delete them manually. But if you have a hundred runs, it might be worth running a simple script. For example, the following python
script uses GitHub API:
Before you start, you need to install the PyGithub
package (like pip install PyGithub
) and define three things:
from github import Github
import requests
token = "ghp_1234567890abcdefghij1234567890123456" # your PAT
repo = "octocat/my_repo"
action = "my_action.yml"
g = Github(token)
headers = {'Accept': 'application/vnd.github.v3',
'Authorization': f'token {token}'}
for run in g.get_repo(repo).get_workflow(id_or_file_name=action).get_runs():
response = requests.delete(url=run.url, headers=headers)
if response.status_code == 204:
print(f"Run {run.id} got deleted")
After all the runs are deleted, the workflow automatically disappears from the page.
Upvotes: 4
Reputation: 1
GitHub cli
GitHub Actions/Manage workflow runs/Deleting a workflow run
# GitHub CLI api
# https://cli.github.com/manual/gh_api
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/OWNER/REPO/actions/runs/RUN_ID/logs
Upvotes: 0
Reputation: 4507
https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run
To delete programmatically
Example (from the docs)
curl \
-X DELETE \
-H "Authorization: token <PERSONAL_ACCESS_TOKEN>"
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/actions/runs/42
Upvotes: 2
Reputation: 225
Yes, you can delete all the workflow runs in the workflow which you want to delete, then this workflow will disappear.
Upvotes: 2