Skip to content

Instantly share code, notes, and snippets.

@ilammy
Created June 12, 2021 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilammy/6e0141029b87e51c58ef65095716f7e6 to your computer and use it in GitHub Desktop.
Save ilammy/6e0141029b87e51c58ef65095716f7e6 to your computer and use it in GitHub Desktop.
Scanning GitHub for repos with Pollen files in them
#!/usr/bin/env bash
#
# Scan GitHub for repositories with Pollen files.
#
# Environment variables:
#
# GITHUB_USER GitHub username
# GITHUB_TOKEN Personal access token on GitHub with "public_repo" scope
set -ueo pipefail
matching_repos() {
local query="$1"
# GitHub search API returns up to 1000 resuls.
for page in $(seq 1 10)
do
curl --silent \
-H "accept: application/vnd.github.v3+json" \
-u "$GITHUB_USER:$GITHUB_TOKEN" \
"https://api.github.com/search/code?q=$query&per_page=100&page=$page" \
| jq -r "[.items[].repository.full_name] | .[]"
echo -n >&2 "."
# Search API has rate-limit of 30 authenticated requests per minute.
sleep 3
done
echo >&2
}
(
matching_repos "lang+pollen+extension:ptree"
matching_repos "lang+pollen+extension:pm"
matching_repos "lang+pollen+extension:pp"
matching_repos "lang+pollen+extension:p"
) | sort -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment