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: 135 comments 162 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.
-
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.
-
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.
-
Any updates on that ? |
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.
-
How is this solved? Any update on this? And what do you mean by won’t be there forever? They do. |
Beta Was this translation helpful? Give feedback.
-
Hi, with all due respect this doesn’t exactly “solve” the problem, is there any update or ETA on this please? Thanks |
Beta Was this translation helpful? Give feedback.
-
We really need this feature… Wanna get rid of those old experimental workflows. |
Beta Was this translation helpful? Give feedback.
-
Hi, any ETA on this? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Has anyone figured a way to clean them? |
Beta Was this translation helpful? Give feedback.
-
Also looking forward to seeing this. |
Beta Was this translation helpful? Give feedback.
-
“solved” = “won’t fix” it seems. |
Beta Was this translation helpful? Give feedback.
-
Hey Guys, i see that many have asked this me also was going to ask, but i found a work around. |
Beta Was this translation helpful? Give feedback.
-
This is not working. I deleted the workflow but still actions has all history of workflow executions. Currently there is no way to get rid of this. |
Beta Was this translation helpful? Give feedback.
-
I tried this myself, make sure you push to github repo after you delete files related to workflow. |
Beta Was this translation helpful? Give feedback.
-
Combining @dmitrym0 comment with the limit 500 in @maximbaz comment (because the default limit is smaller). Make sure you
|
Beta Was this translation helpful? Give feedback.
-
I have a unique issue that is related. Our repo has no workflow runs of a now renamed (added https://github.com/Botspot/pi-apps/actions/workflows/update_apps_raspbian_addons.yml running So for me there is no workaround available for getting this workflow to not show up. |
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.
-
If you really hate seeing hang around, try bringing it back and add a dummy run (something like |
Beta Was this translation helpful? Give feedback.
-
I really want to delete old actions. |
Beta Was this translation helpful? Give feedback.
-
would love to see this |
Beta Was this translation helpful? Give feedback.
-
https://github.com/orgs/community/discussions/26256#discussioncomment-7295831 |
Beta Was this translation helpful? Give feedback.
-
I think you can do as follows. First, you create a new script, here I name it name: Remove Expired Workflow Runs
on:
schedule: [{ cron: "30 1 * * *" }] # Schedule to run the workflow every day at 1:30 AM
workflow_dispatch:
jobs:
clean:
name: Delete Expired Workflow Runs
runs-on: ubuntu-latest
steps:
- name: Checkout Action Code
uses: actions/checkout@v2
- name: Run Delete Script
# run: sh ./delete.sh (your org or github name) (your repo name)
run: sh ./delete.sh Long18 github-test-action
working-directory: .github/actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Next, I have a new script, I name it #!/bin/bash
org="$1"
repo="$2"
echo "Deleting workflow runs for $org/$repo"
workflows_temp=$(mktemp) # Creates a temporary file to store workflow data.
gh api repos/$org/$repo/actions/workflows | jq -r '.workflows[] | [.id, .path] | @tsv' > $workflows_temp # Lookup workflow
cat "$workflows_temp"
workflows_names=$(awk '{print $2}' $workflows_temp | grep -v "main")
if [ -z "$workflows_names" ]; then
echo "All workflows are either successful or failed. Nothing to remove"
else
echo "Removing all the workflows that are not successful or failed"
for workflow_name in $workflows_names; do
workflow_filename=$(basename "$workflow_name")
echo "Deleting |$workflow_filename|, please wait..."
gh run list --limit 500 --workflow $workflow_filename --json databaseId |
jq -r '.[] | .databaseId' |
xargs -I{} gh run delete {} # Delete all workflow runs for workflow name
done
fi
rm -rf $workflows_temp
echo "Done." That's it, you're done. Good luck! |
Beta Was this translation helpful? Give feedback.
-
How is there not a proper solution for this yet |
Beta Was this translation helpful? Give feedback.
-
not sure this would work for everyone but it worked for me: create an archived folder and move the workflow files to that folder on the default (e.g. main/master) branch of your repo |
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.
-
I used this workflow to remove all previous workflow runs, and I am happy with it: main project: https://github.com/Mattraks/delete-workflow-runs I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Upvote for a "Delete all runs" button. |
Beta Was this translation helpful? Give feedback.
-
I used this script and it works well #!/bin/bash
# Fetch all run IDs for the specified workflow using --json for structured output
run_ids=$(gh run list --limit 500 --repo=zuplo/core --workflow=workflow-name.yaml --json databaseId | jq -r '.[].databaseId')
# Loop through each run ID and delete it
for run_id in $run_ids; do
gh run delete $run_id --repo zuplo/core
done |
Beta Was this translation helpful? Give feedback.
-
Apparently we can no longer |
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.