Skip to content

Commit aa90bad

Browse files
committed
chore: fetch repo metadata daily
1 parent 61d9934 commit aa90bad

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# triggers on a cron, every day at 12:00 AM UTC
2+
3+
on:
4+
schedule:
5+
- cron: '0 12 * * *'
6+
# also triggered from the github UI
7+
workflow_dispatch:
8+
9+
jobs:
10+
fetch_repo_metadata:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v5
14+
with:
15+
submodules: true
16+
- name: Fetch repo metadata
17+
id: fetch_repo_metadata
18+
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
run: |
21+
./.github/workflows/fetch_repo_metadata.sh
22+
- name: Upload metadata
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: github_metadata
26+
path: ${{ steps.fetch_repo_metadata.outputs.metadata }}

0 commit comments

Comments
 (0)