|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -o errexit -o nounset -o pipefail |
| 4 | + |
| 5 | +# Minimum required version: https://github.com/cli/cli/releases/tag/v2.49.0 |
| 6 | +REQUIRED_GH_VERSION="2.49.0" |
| 7 | + |
| 8 | +# Check if gh is available |
| 9 | +if ! command -v gh &> /dev/null; then |
| 10 | + echo "Error: GitHub CLI (gh) is not installed or not in your PATH." |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +# Ensure gh is logged in |
| 15 | +if ! gh auth status &> /dev/null; then |
| 16 | + echo "Error: GitHub CLI (gh) is not logged in." |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +OUT=$(mktemp -d) |
| 21 | +# current script directory |
| 22 | +SCRIPT_DIR=$(dirname "$0") |
| 23 | +( |
| 24 | + cd $SCRIPT_DIR/../../data/bazel-central-registry/modules |
| 25 | + for module in $(ls); do |
| 26 | + # GraphQL: Although you appear to have the correct authorization credentials, the `confluentinc` organization has an IP allow list enabled, and your IP address is not permitted to access this resource. |
| 27 | + if [[ "$module" == "librdkafka" ]]; then |
| 28 | + echo " Skipping $module (known access restrictions)" |
| 29 | + continue |
| 30 | + fi |
| 31 | + |
| 32 | + echo "Fetching metadata for $module" |
| 33 | + organdrepo=$(jq --raw-output <$module/metadata.json '.repository[] | select(startswith("github:")) | sub("github:"; "")' | head -1) |
| 34 | + |
| 35 | + # Skip if no GitHub repository found |
| 36 | + if [[ -z "$organdrepo" || "$organdrepo" == "null" ]]; then |
| 37 | + echo " No GitHub repository found, skipping..." |
| 38 | + continue |
| 39 | + fi |
| 40 | + |
| 41 | + gh repo view --json description,licenseInfo,repositoryTopics,stargazerCount "$organdrepo" > $OUT/$module.github_metadata.json |
| 42 | + done |
| 43 | +) |
| 44 | + |
| 45 | +ARCHIVE=github_metadata.tar.gz |
| 46 | +tar --create --auto-compress \ |
| 47 | + --directory "$OUT" \ |
| 48 | + --file "$ARCHIVE" . |
| 49 | + |
| 50 | +echo metadata=$PWD/$ARCHIVE > ${GITHUB_OUTPUT:-/dev/stdout} |
0 commit comments