|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | +set -u |
| 4 | +set -o pipefail |
| 5 | + |
| 6 | +## DESCRIPTION: |
| 7 | +## |
| 8 | +## This script checks for open issues with the 'release-blocker' label |
| 9 | +## in a given GitHub repository. It exits with code 1 if any blocking |
| 10 | +## issues are found, or 0 if none are found. |
| 11 | +## |
| 12 | +## PRE-REQS: |
| 13 | +## |
| 14 | +## This script assumes that the gh cli is installed and in the PATH |
| 15 | +## and that there is a GitHub PAT in the GITHUB_TOKEN env var |
| 16 | +## with the following permissions: |
| 17 | +## - repo (read) |
| 18 | +## - issues (read) |
| 19 | +## or that the user is logged into the gh cli with an account with those permissions |
| 20 | + |
| 21 | + |
| 22 | +# Check if repository argument is provided |
| 23 | +if [ -z "${1:-}" ]; then |
| 24 | + echo "Error: Repository name not provided." |
| 25 | + echo "Usage: $0 <owner/repo>" |
| 26 | + echo "Example: $0 hyperlight-dev/hyperlight" |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +REPO="$1" |
| 31 | +echo "Checking for open issues with 'release-blocker' label in $REPO..." |
| 32 | + |
| 33 | +# Extract owner and repo name from the argument |
| 34 | +OWNER=$(echo "$REPO" | cut -d'/' -f1) |
| 35 | +REPO_NAME=$(echo "$REPO" | cut -d'/' -f2) |
| 36 | + |
| 37 | +# Get all open issues with release-blocker label |
| 38 | +BLOCKING_ISSUES=$(gh api graphql -f query=' |
| 39 | + query($owner: String!, $repo: String!) { |
| 40 | + repository(owner: $owner, name: $repo) { |
| 41 | + issues(first: 100, states: OPEN, labels: ["release-blocker"]) { |
| 42 | + totalCount |
| 43 | + nodes { |
| 44 | + number |
| 45 | + title |
| 46 | + url |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + }' -f owner="$OWNER" -f repo="$REPO_NAME" --jq '.data.repository.issues') |
| 51 | + |
| 52 | +BLOCKER_COUNT=$(echo "$BLOCKING_ISSUES" | jq '.totalCount') |
| 53 | + |
| 54 | +if [ "$BLOCKER_COUNT" -gt 0 ]; then |
| 55 | + echo "❌ Found $BLOCKER_COUNT open release-blocking issue(s):" |
| 56 | + echo "$BLOCKING_ISSUES" | jq -r '.nodes[] | " - #\(.number): \(.title) (\(.url))"' |
| 57 | + echo "" |
| 58 | + echo "Release blocked by open issue(s) with 'release-blocker' label" |
| 59 | + exit 1 |
| 60 | +else |
| 61 | + echo "✅ No open release blocking issues found" |
| 62 | + exit 0 |
| 63 | +fi |
0 commit comments