CloudQuery News

Introducing the GitHub CloudQuery Plugin

Ron Eliahu

Ron Eliahu

GitHub is a source-control provider that helps developers store and manage their code, as well as track and control changes to their code.
In this tutorial, we will install CloudQuery and use it to fetch GitHub resources. Then, we will use SQL to get visibility into security, compliance and cost-management in GitHub.

Setup #

  • Acquire a GitHub personal access token with the scopes:
    read:org
      read:project
      public_repo
    ```.
  • Create a cloudquery.yml file, similar to the following:
    kind: source
    spec:
      name: github
      path: cloudquery/github
      registry: cloudquery
      version: 'v11.11.0'
      tables: ['*']
      destinations: ['postgresql']
    
      spec:
        access_token: <YOUR_ACCESS_TOKEN>
        orgs: ['cloudquery']
    ---
    kind: destination
    spec:
      name: 'postgresql'
      path: cloudquery/postgresql
      registry: cloudquery
      version: 'v8.6.8'
      write_mode: 'overwrite-delete-stale'
    
      spec:
        connection_string: 'postgresql://postgres:pass@localhost:5432/postgres?sslmode=disable'
  • Run
    cloudquery sync cloudquery.yml

Use Cases #

After we finish fetching our config data we can make queries for security, compliance, cost management and other purposes.

Find all Public Repositories #

-- Query all repositories in the organizations that are public
SELECT id, org, name, description FROM github_repositories
WHERE private = false

Organization Billing #

-- Get billing information state for actions, packages and storage
SELECT * FROM github_billing_action

SELECT * FROM github_billing_package

SELECT * FROM github_billing_storage

Long Standing Open Issues #

-- Find all open issues that have been open for more than 7 days
SELECT gr.org, gr.name, gi.id, gi.state, gi.created_at, gi.updated_at
FROM github_issues gi
INNER JOIN github_repositories gr ON gr.id = (gi.repository->'id')::bigint
WHERE state = 'open' AND NOW() - interval '7 days' > gi.created_at

What's next #

We are going to continue expanding the GitHub Provider, adding support for more resources. Interested in seeing another plugin? Check out Developing New plugin and/or open an issue on our GitHub.
Ready to get started with CloudQuery? You can try out CloudQuery locally with our quick start guide or explore the CloudQuery Platform (currently in beta) for a more scalable solution.
Want help getting started? Join the CloudQuery community to connect with other users and experts, or message our team directly here if you have any questions.
Ron Eliahu

Written by Ron Eliahu

Ron is a software engineer with a passion for building open source projects and databases. He is proficient in JavaScript, MongoDB and React and has experience in Python, C# and SQL. Additionally, he is familiar with PHP, Angular and Redis. Ron has contributed to a number of GitHub projects including a real time coding collaboration project for students and an image matching service that helps people locate lost pets.

Turn cloud chaos into clarity

Find out how CloudQuery can help you get clarity from a chaotic cloud environment with a personalized conversation and demo.

Join our mailing list

Subscribe to our newsletter to make sure you don't miss any updates.

Legal

© 2024 CloudQuery, Inc. All rights reserved.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve. You can always opt out later via the link in the footer.