'Is there a way to delete a github workflow
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?
Solution 1:[1]
Yes, you can delete the results of a run. See the documentation for details.
Solution 2:[2]
Yes, you can delete all the workflow runs in the workflow which you want to delete, then this workflow will disappear.
Solution 3:[3]
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
Solution 4:[4]
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 been 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 of runs, it might worth running a simple script. For example the following python script uses GitHub API:
Before you start, you need to define three things:
- PAT: create a new personal access GitHub token;
- your repo name
- your action name (even you got deleted it already, just hover over the action on the actions page):
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_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 runs are deleted, the workflow automatically disappears from the page.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jidicula |
| Solution 2 | HUAN XIE |
| Solution 3 | Phani Rithvij |
| Solution 4 | Yury Kirienko |
