File tree Expand file tree Collapse file tree 1 file changed +36
-4
lines changed
Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,42 @@ jobs:
1515 - name : Count repos using GitHub Code Search
1616 id : count
1717 run : |
18- COUNT=$(curl -s -H "Accept: application/vnd.github+json" \
19- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
20- "https://api.github.com/search/code?q=@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol+in:file" \
21- | jq -r '.items[].repository.html_url' | sort -u | wc -l)
18+ set -euo pipefail
19+
20+ # Build search query; include fork:false to exclude forks (remove if undesired)
21+ QUERY='@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol in:file fork:false'
22+ # URL-encode the query using jq
23+ ENCODED_QUERY=$(jq -rn --arg q "$QUERY" '$q|@uri')
24+
25+ PER_PAGE=100
26+ PAGE=1
27+ TMP=$(mktemp)
28+ trap 'rm -f "$TMP"' EXIT
29+ : > "$TMP"
30+
31+ while :; do
32+ RESP=$(curl -sS \
33+ -H "Accept: application/vnd.github+json" \
34+ -H "X-GitHub-Api-Version: 2022-11-28" \
35+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
36+ "https://api.github.com/search/code?q=${ENCODED_QUERY}&per_page=${PER_PAGE}&page=${PAGE}")
37+
38+ ITEMS_LEN=$(echo "$RESP" | jq '.items | length')
39+ if [ -z "$ITEMS_LEN" ] || [ "$ITEMS_LEN" -eq 0 ]; then
40+ break
41+ fi
42+
43+ echo "$RESP" | jq -r '.items[].repository.html_url' >> "$TMP"
44+
45+ # Stop if this page returned fewer than PER_PAGE items
46+ if [ "$ITEMS_LEN" -lt "$PER_PAGE" ]; then
47+ break
48+ fi
49+
50+ PAGE=$((PAGE+1))
51+ done
52+
53+ COUNT=$(sort -u "$TMP" | grep -c . || true)
2254 echo "Repositories using GatewayZEVM.sol: $COUNT"
2355 echo "count=$COUNT" >> "$GITHUB_OUTPUT"
2456
You can’t perform that action at this time.
0 commit comments