Skip to main content

How to query GitHub repositories with StackQL

GitHub repositories are exposed as the table github.repos.repos. Listing by organization or user maps to the corresponding GitHub REST operations, selected by the WHERE clause: org = '...' uses the organization listing, username = '...' the user listing.

Prerequisites

List an organization's repositories

SELECT name, description, language, stargazers_count
FROM github.repos.repos
WHERE org = 'stackql';

Run against the public stackql organization, this returns rows such as the stackql engine repository (Go, 861 stars at the time of writing) and stackql-provider-registry - live API data, no snapshot involved.

Filter on repository attributes

Standard SQL predicates apply to any column:

SELECT name, visibility, default_branch, archived
FROM github.repos.repos
WHERE org = 'my-org'
AND archived = false
AND visibility = 'public';

Useful governance columns include private, visibility, archived, fork, default_branch, delete_branch_on_merge, has_wiki, topics, created_at, pushed_at, and security_and_analysis. DESCRIBE github.repos.repos lists all of them.

Beyond the repository list

The github.repos service exposes the rest of the repository surface as sibling tables - github.repos.branches, github.repos.commits, github.repos.releases, github.repos.collaborators, github.repos.webhooks, github.repos.deployments, and more. Discover them with:

SHOW RESOURCES IN github.repos;

Updating repositories

Repository settings changes are UPDATE statements; the method requires owner and repo, and body fields use the data__ prefix:

UPDATE github.repos.repos
SET data__delete_branch_on_merge = true
WHERE owner = 'my-org' AND repo = 'my-repo';

Applied across a result set from the listing query, this is fleet-wide repository governance in two statements - a pattern that pairs naturally with cross-provider queries joining GitHub data to cloud resources.