Skip to content

Commit

Permalink
improve pruning output
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Coder committed Jun 25, 2024
1 parent 063ce64 commit 18cbcaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 17 additions & 1 deletion .github/prune-all-caches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,25 @@ KEYS=(

cd $(dirname "$0")

# use CLI args or default from env / working dir
REPO="${3:-${GITHUB_REPOSITORY:-$(gh repo view --json nameWithOwner --jq .nameWithOwner)}}"

function usage() {
gh api "/repos/$REPO/actions/cache/usage" | jq --raw-output \
'"Repo: " + (.full_name | tostring) +
"\nCache Count: " + (.active_caches_count | tostring) +
"\nCache Size: " + (.active_caches_size_in_bytes / 1024 / 1024 / 1024 * 100 | round | . / 100 | tostring) + "GB"'
echo
}

usage

for ref in $(gh cache list --json ref --jq ".[].ref" | sort | uniq); do
echo "Pruning ref $ref..."
for key in ${KEYS[@]}; do
./prune-caches.sh "$key" "$ref"
./prune-caches.sh "$key" "$ref" "$REPO"
done
echo
done

usage
6 changes: 3 additions & 3 deletions .github/prune-caches.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

# use CLI args or default from env
# use CLI args or default from env / working dir
KEY="$1"
REF="${2:-${WORKFLOW_REF:-${GITHUB_REF:-refs/heads/master}}}"
REPO="${3:-${GITHUB_REPOSITORY:-ogdf/ogdf}}"
REF="${2:-${WORKFLOW_REF:-${GITHUB_REF:-$(git symbolic-ref HEAD)}}}"
REPO="${3:-${GITHUB_REPOSITORY:-$(gh repo view --json nameWithOwner --jq .nameWithOwner)}}"

if [[ -z "$KEY" ]]; then
echo "Need to specify a cache key as first arg!"
Expand Down

0 comments on commit 18cbcaf

Please sign in to comment.