diff --git a/util/GHA-delete-GNU-workflow-logs.sh b/util/GHA-delete-GNU-workflow-logs.sh index 95f5c240eb..de21de9d18 100755 --- a/util/GHA-delete-GNU-workflow-logs.sh +++ b/util/GHA-delete-GNU-workflow-logs.sh @@ -1,7 +1,5 @@ #!/bin/sh -# spell-checker:ignore (utils) gitsome jq jaq ; (gh) repos - # ME="${0}" # ME_dir="$(dirname -- "${ME}")" # ME_parent_dir="$(dirname -- "${ME_dir}")" @@ -9,16 +7,10 @@ # ref: -# note: requires `gh` and `jq` - -## tools available? - -# * `gh` available? -GH=$(command -v gh) -"${GH}" --version || (echo "ERR!: missing \`gh\` (see install instructions at )"; exit 1) -# * `jq` or fallback available? -: ${JQ:=$(command -v jq || command -v jaq)} -"${JQ}" --version || (echo "ERR!: missing \`jq\` (install with \`sudo apt install jq\`)"; exit 1) +if ! command -v gh >/dev/null 2>&1; then + echo "ERR!: missing \`gh\` (see install instructions at )" 1>&2 + exit 1 +fi case "${dry_run}" in '0' | 'f' | 'false' | 'no' | 'never' | 'none') unset dry_run ;; @@ -30,7 +22,7 @@ REPO_NAME="${REPO_NAME:-coreutils}" WORK_NAME="${WORK_NAME:-GNU}" # * `--paginate` retrieves all pages -# gh api --paginate "repos/${USER_NAME}/${REPO_NAME}/actions/runs" | jq -r ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" | xargs -n1 sh -c "for arg do { echo gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z "$dry_run" ]; then gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _ -"${GH}" api "repos/${USER_NAME}/${REPO_NAME}/actions/runs" | - "${JQ}" -r ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" | - xargs -n1 sh -c "for arg do { echo ${GH} api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z \"${dry_run}\" ]; then ${GH} api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _ +# gh api --paginate "repos/${USER_NAME}/${REPO_NAME}/actions/runs" --jq ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" | xargs -n1 sh -c "for arg do { echo gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z "$dry_run" ]; then gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _ +gh api "repos/${USER_NAME}/${REPO_NAME}/actions/runs" \ + --jq ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" | + xargs -n1 sh -c "for arg do { echo gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z \"${dry_run}\" ]; then gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _