steampipe plugin install github

Table: github_repository_content - Query File and Directory Contents in GitHub Repositories using SQL

The github_repository_content table is designed to fetch the contents of files or directories within a GitHub repository. It provides a detailed view of file paths, types, contents, sizes, and other related information.

Table Usage Guide

To utilize this table effectively, specify the file path or directory within repository_content_path. If repository_content_path is not specified, the table will return the contents of the repository's root directory. This feature allows for comprehensive exploration of repository contents, from individual files to entire directories.

Important Notes

  • It's mandatory to specify the repository_full_name (including the organization/user prefix) in the where or join clause when querying this table.
  • To enhance performance, this table supports the optional qualifier repository_content_path. Queries that utilize this qualifier are optimized to efficiently retrieve file contents from a sub-directory within a repository.

Examples

List the root directory contents of a repository

This query is useful for obtaining an overview of the root directory of a specific repository, helping users quickly identify the initial set of files and directories it contains.

select
repository_full_name,
path,
content,
type,
size,
sha
from
github_repository_content
where
repository_full_name = 'github/docs';
select
repository_full_name,
path,
content,
type,
size,
sha
from
github_repository_content
where
repository_full_name = 'github/docs';

Get file contents under a folder in a repository

This enables retrieval of the file contents within a specific directory.

select
repository_full_name,
name,
type,
path,
content
from
github_repository_content
where
repository_full_name = 'turbot/steampipe-plugin-aws'
and repository_content_path = 'aws-tests/tests';
select
repository_full_name,
name,
type,
path,
content
from
github_repository_content
where
repository_full_name = 'turbot/steampipe-plugin-aws'
and repository_content_path = 'aws-tests/tests';

List contents of a specific directory within a repository

This query facilitates a deeper inspection of a specific directory within a repository, enabling users to understand its structure and the types of files it contains.

select
repository_full_name,
path,
content,
type,
size,
sha
from
github_repository_content
where
repository_full_name = 'github/docs'
and repository_content_path = 'docs';
select
repository_full_name,
path,
content,
type,
size,
sha
from
github_repository_content
where
repository_full_name = 'github/docs'
and repository_content_path = 'docs';

Retrieve a specific file within a repository

Targeting a specific file within a repository, this query is particularly useful for extracting detailed information about a file, such as its content, type, and size, which is essential for analysis or integration purposes.

select
repository_full_name,
path,
type,
size,
sha,
content
from
github_repository_content
where
repository_full_name = 'github/docs'
and repository_content_path = '.vscode/settings.json';
select
repository_full_name,
path,
type,
size,
sha,
content
from
github_repository_content
where
repository_full_name = 'github/docs'
and repository_content_path = '.vscode/settings.json';

Schema for github_repository_content

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
abbreviated_oidtextAn abbreviated version of the Git object ID.
commit_urltextGit URL (with SHA) of the file.
contenttextThe decoded file content (if the element is a file).
is_binarybooleanIndicates whether the Blob is binary or text.
is_generatedbooleanWhether or not this tree entry is generated.
line_countbigintThe number of lines available in the file.
modebigintThe mode of the file.
nametextThe file name.
oidtextThe Git object ID.
pathtext=The path of the file.
path_rawtextA Base64-encoded representation of the file's path.
repository_content_pathtext=The requested path in repository search.
repository_full_nametext=The full name of the repository (login/repo-name).
sizebigintThe size of the file (in KB).
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
typetextThe file type (directory or file).

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- github

You can pass the configuration to the command with the --config argument:

steampipe_export_github --config '<your_config>' github_repository_content