Is there a way to delete or hide old/renamed Workflows? #26256
-
I made a Workflow using the Node CI template and then later renamed it. Now my Workflow list has “Node CI” in it, but that doesnt even exist anymore. Is there some way for me to hide it? Or is it there forever? |
Beta Was this translation helpful? Give feedback.
Replies: 131 comments 145 replies
-
You can’t remove it yet, but it won’t be there forever. You can’t delete it yet but we’ll have functionality to delete this in the future. |
Beta Was this translation helpful? Give feedback.
-
I got all excited when I saw this was marked as “solved/go to solution”. Then I found the solution was to wait as it would be fixed sometime in the future! We could close all our issues right now with the same message 😉 Seriously though, while we love actions and are creating/recreating lots of them, our actions page littered with orphaned action detritus. |
Beta Was this translation helpful? Give feedback.
-
I had a fair amount of workflow runs to delete. This is what I did using the GitHub CLI: # Lookup workflow ID
gh api repos/<org>/<repo>/actions/workflows | jq -cM '.workflows[] | [.id, .name, .path]'
# Delete all workflow runs for workflow ID
gh api repos/<org>/<repo>/actions/workflows/<workflow_id>/runs --paginate | jq '.workflow_runs[] | .id' | xargs -n1 -t -I% gh api repos/<org>/<repo>/actions/runs/% -X DELETE |
Beta Was this translation helpful? Give feedback.
-
Just a +1 to say I would like to see this issue resolved. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Its been 3 months since this post? Can I delete yet? Its annoying that a typo leaves an action in the workflow |
Beta Was this translation helpful? Give feedback.
-
I really want to delete old actions. |
Beta Was this translation helpful? Give feedback.
-
It's been 3 years and you still can't remove a workflow once it has run once? |
Beta Was this translation helpful? Give feedback.
-
The fact that this is a 5 year old issue is WILD 💀 |
Beta Was this translation helpful? Give feedback.
-
@github-staff If you onboard your next new dev, why don't you let him implement this to get started with the codebase. The users of your product will be thankful |
Beta Was this translation helpful? Give feedback.
-
Hi. I'm from the future and can tell you that the promise from 2019 was a lie. 😉 |
Beta Was this translation helpful? Give feedback.
-
i deleted all runs, but still the ghost-wf's show up in the list. it would be really cool to manually delete them via the web-ui. all you can do right now is to deactivate them - at least this gives some hint on what's up2date and what is no longer in use/existing. |
Beta Was this translation helpful? Give feedback.
-
I wrote simple python scripts for resolving this issue. ResultDelete github actions workflow runs by name# resolves : Is there a way to delete or hide old/renamed Workflows? #26256
# https://github.com/community/community/discussions/26256
from multiprocessing.dummy import Pool as ThreadPool
import requests
TOKEN = "{YOUR_GH_TOKEN}"
OWNER_REPO = "esc5221/example_repo"
DELETE_TARGET_RUN_NAME = "{RUN NAME}"
headers = {
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {TOKEN}",
}
PER_PAGE = 100
def list_all_runs(owner_repo):
url = f"https://api.github.com/repos/{owner_repo}/actions/runs"
url_with_params = f"{url}?per_page=1"
total_count = requests.get(url, headers=headers).json()["total_count"]
page_count = total_count // PER_PAGE + 1
print("total_count: ", total_count)
def _list_runs_by_page(page):
url_with_params = f"{url}?page={page}&per_page={PER_PAGE}"
runs_list = requests.get(url_with_params, headers=headers).json()
page_workflow_runs = runs_list["workflow_runs"]
return page_workflow_runs
merged_workflow_runs = []
with ThreadPool(10) as p:
merged_workflow_runs = p.map(_list_runs_by_page, range(1, page_count + 1))
return [run for runs in merged_workflow_runs for run in runs]
def filter_runs_by_name(runs_list, name):
filtered_runs = [run for run in runs_list if run["name"] == name]
return filtered_runs
def remove_runs(owner_repo, runs_list):
def remove_run_by_id(run_id):
url = f"https://api.github.com/repos/{owner_repo}/actions/runs/{run_id}"
requests.delete(url, headers=headers)
with ThreadPool(10) as p:
p.map(remove_run_by_id, [run["id"] for run in runs_list])
print("removed runs: ", len(runs_list))
def main():
runs = list_all_runs(OWNER_REPO)
delete_target_runs = filter_runs_by_name(runs, DELETE_TARGET_RUN_NAME)
remove_runs(OWNER_REPO, delete_target_runs)
if __name__ == "__main__":
main() |
Beta Was this translation helpful? Give feedback.
-
How is there not a proper solution for this yet |
Beta Was this translation helpful? Give feedback.
-
You can delete old workflows by deleting all workflow runs, and that in turn you can automate using CLI: gh run list --limit 500 --workflow '<workflow name>' --json databaseId | jq -r '.[] | .databaseId | @sh' | xargs -I{} gh run delete "{}" Using the script above I was able to quickly cleanup multiple old workflows that had hundreds of runs 🙂 |
Beta Was this translation helpful? Give feedback.
-
Hi, any updates on this issue/feature? we have several spurious workflows here: https://github.com/devitocodes/devito/actions and we’re really looking forward for some clean up … Thanks! |
Beta Was this translation helpful? Give feedback.
-
here y'all go. |
Beta Was this translation helpful? Give feedback.
-
at least just make it a view so we can select which workflows to show by default. you promote your this actions feature a lot, don't make people leave by this simple issue. |
Beta Was this translation helpful? Give feedback.
-
I just noticed that workflows that no longer exist on my main branch are no longer visible in the actions overview. So my guess is that if it isn't present in any active branch it no longer shows? |
Beta Was this translation helpful? Give feedback.
-
+1 to the feature. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
For my use case, I wanted to remove a Workflow entirely from the Actions UI. Removing workflows from the main branch of my repository was not sufficient, nor was deleting the logs of the workflows' runs (what is documented by GitHub here: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/using-workflow-run-logs#deleting-logs-programmatically). So modeled after GitHub's logs script, and using wisdom from https://github.com/orgs/community/discussions/26256#discussioncomment-8756475 I have this script that deletes all the runs from a workflow, and therefore will remove from it the UI once it completes: #!/usr/bin/env bash
# Delete all the runs for a given workflow
# Usage: delete-runs.sh <repository> <workflow-name>
set -oe pipefail
REPOSITORY=$1
WORKFLOW_NAME=$2
# Validate arguments
if [[ -z "$REPOSITORY" ]]; then
echo "Repository is required"
exit 1
fi
if [[ -z "$WORKFLOW_NAME" ]]; then
echo "Workflow name is required"
exit 1
fi
echo "Getting all completed runs for workflow $WORKFLOW_NAME in $REPOSITORY"
RUNS=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$REPOSITORY/actions/workflows/$WORKFLOW_NAME/runs" \
--paginate \
--jq '.workflow_runs[] | select(.conclusion != "") | .id'
)
echo "Found $(echo "$RUNS" | wc -l) completed runs for workflow $WORKFLOW_NAME"
for RUN in $RUNS; do
gh run delete --repo $REPOSITORY $RUN || echo "Failed to delete run $RUN"
sleep 0.1
done I'll edit the script if I find for workflows that had non-completed runs if it doesn't finish cleaning them up. Hope this helps folks! GitHub please make this possible via the UI soon. It's a bit absurd its taken five years to prioritize creating a UI button and an API that in the backend just has to do the above 🤷🏻. |
Beta Was this translation helpful? Give feedback.
You can’t remove it yet, but it won’t be there forever. You can’t delete it yet but we’ll have functionality to delete this in the future.