ci(nightly): delete nightly* releases with gh CLI
Made-with: Cursor
This commit is contained in:
30
.github/workflows/nightly.yml
vendored
30
.github/workflows/nightly.yml
vendored
@@ -22,29 +22,15 @@ jobs:
|
||||
echo "date=$(date +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Delete existing nightly releases
|
||||
shell: bash {0}
|
||||
run: |
|
||||
API="${GITHUB_API_URL:-https://api.github.com}"
|
||||
REPO="${GITHUB_REPOSITORY}"
|
||||
HDR="Authorization: Bearer ${GITHUB_TOKEN}"
|
||||
|
||||
# Delete all releases whose tag starts with "nightly"
|
||||
curl -sS -H "$HDR" "${API}/repos/${REPO}/releases?per_page=100" \
|
||||
| grep -oE '"id":[0-9]+|"tag_name":"[^"]+"' \
|
||||
| paste - - \
|
||||
| while read -r line; do
|
||||
ID=$(echo "$line" | grep -oE '"id":([0-9]+)' | grep -oE '[0-9]+')
|
||||
TAG=$(echo "$line" | grep -oE '"tag_name":"([^"]+)"' | cut -d'"' -f4)
|
||||
if echo "$TAG" | grep -q '^nightly'; then
|
||||
echo "Deleting release $ID ($TAG)"
|
||||
curl -sS -X DELETE -H "$HDR" "${API}/repos/${REPO}/releases/${ID}" || true
|
||||
fi
|
||||
done
|
||||
|
||||
# Delete all tags starting with "nightly"
|
||||
git tag -l 'nightly*' | while read -r TAG; do
|
||||
echo "Deleting tag $TAG"
|
||||
curl -sS -X DELETE -H "$HDR" "${API}/repos/${REPO}/git/refs/tags/${TAG}" || true
|
||||
done
|
||||
set -euo pipefail
|
||||
gh release list --limit 500 --json tagName \
|
||||
| jq -r '.[] | select(.tagName | startswith("nightly")) | .tagName' \
|
||||
| while read -r tag; do
|
||||
[ -z "$tag" ] && continue
|
||||
gh release delete "$tag" --yes --cleanup-tag
|
||||
done
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user