-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: remove unneeded / untested workflows (#487)
* update workflow for deploy based on tag. * give workflow better name, fix env. refs. * this needs work, not functional now. * handy cleanup script to clear out old workflows * give the workflow for running Go tests a more descriptive name * remove duplicate workflow. * update cleanup script to handle multiple workflows with same name * fix auth pattern to GCP
- Loading branch information
Showing
5 changed files
with
66 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "Error: No workflow name provided." | ||
echo "Usage: $0 <workflow-name>" | ||
exit 1 | ||
fi | ||
|
||
WORKFLOW_NAME="$1" | ||
|
||
echo "Fetching repository information..." | ||
REPO_INFO=$(gh repo view --json nameWithOwner) | ||
REPO=$(echo $REPO_INFO | jq -r .nameWithOwner) | ||
echo "Repository: $REPO" | ||
|
||
echo "Searching for workflows with name: '$WORKFLOW_NAME'" | ||
WORKFLOW_IDS=$(gh api "/repos/$REPO/actions/workflows" | jq -r ".workflows[] | select(.name == \"$WORKFLOW_NAME\") | .id") | ||
|
||
if [ -z "$WORKFLOW_IDS" ]; then | ||
echo "No workflows found with name '$WORKFLOW_NAME'" | ||
exit 1 | ||
fi | ||
|
||
echo "Found workflow(s) with ID(s): $WORKFLOW_IDS" | ||
|
||
delete_runs() { | ||
local workflow_id=$1 | ||
local page=$2 | ||
echo "Fetching runs for workflow $workflow_id (page $page)..." | ||
RUNS=$(gh api "/repos/$REPO/actions/workflows/$workflow_id/runs?per_page=100&page=$page") | ||
RUN_COUNT=$(echo $RUNS | jq '.workflow_runs | length') | ||
|
||
if [ "$RUN_COUNT" -eq 0 ]; then | ||
return 1 | ||
fi | ||
|
||
echo "Deleting $RUN_COUNT runs..." | ||
echo $RUNS | jq -r '.workflow_runs[].id' | while read -r run_id; do | ||
echo "Deleting run $run_id" | ||
gh api -X DELETE "/repos/$REPO/actions/runs/$run_id" | ||
done | ||
|
||
return 0 | ||
} | ||
|
||
for WORKFLOW_ID in $WORKFLOW_IDS; do | ||
echo "Processing workflow ID: $WORKFLOW_ID" | ||
page=1 | ||
while delete_runs $WORKFLOW_ID $page; do | ||
((page++)) | ||
done | ||
|
||
echo "All runs deleted for workflow ID $WORKFLOW_ID" | ||
|
||
echo "Deleting the workflow itself..." | ||
gh api -X DELETE "/repos/$REPO/actions/workflows/$WORKFLOW_ID" | ||
|
||
echo "Workflow with ID $WORKFLOW_ID has been deleted." | ||
done | ||
|
||
echo "All workflows named '$WORKFLOW_NAME' and their runs have been deleted." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters