Connect CoCo in Snowsight to GitHub¶
Introduction¶
You can connect your GitHub account to Cortex Code (CoCo) in Snowsight. After you connect, CoCo can clone your repositories, push branches, and open pull requests on your behalf, so that you can work on code in GitHub without leaving Snowsight.
CoCo connects to GitHub through the Snowflake CoCo GitHub App and OAuth. Each user authorizes CoCo with their own GitHub account, so CoCo can access only the repositories that the user’s GitHub account can access.
Setup has two parts:
- An administrator sets up the integration once. A GitHub organization administrator installs the Snowflake CoCo GitHub App, and a Snowflake account administrator creates a security integration for it. For instructions, see set up the GitHub integration.
- Each user connects their GitHub account. For instructions, see connect your GitHub account.
Important
When you use this integration, you are directing Snowflake to send or receive data between the Snowflake Service and GitHub. Snowflake is not responsible for the privacy, security, or integrity of data once it leaves the Snowflake Service boundary. Your use of GitHub, and any data you process with it, is governed solely by the terms between you and GitHub.
AI-generated content
AI can make mistakes. CoCo is powered by large language models (LLMs). AI-generated output (including code, commits, branches, and pull requests) may be inaccurate, incomplete, inappropriate, or biased. Review changes before you merge them, and apply human oversight to any decisions based on them.
For more information, see the Legal notices at the bottom of this page.
Set up the GitHub integration¶
Before you begin¶
Make sure that you have the following:
- A Snowflake account that is enabled for this preview. To request access, contact your Snowflake account team.
- The
ACCOUNTADMINrole in that Snowflake account. - Administrator access to the GitHub organization or account that owns the repositories that you want CoCo to work with.
Install the Snowflake CoCo GitHub App¶
A GitHub organization administrator installs the Snowflake CoCo GitHub App on the GitHub organization or account. During the installation, choose which repositories the app can access.
Create the security integration¶
Using the ACCOUNTADMIN role, create a security integration for GitHub, grant USAGE on it to the roles whose users
need GitHub access, and then enable it:
-
Create the security integration. Setting
ENABLED = FALSEcreates it in a disabled state, so that no one can use it until you finish granting access:API_READ_ALLOWED_PREFIXESandAPI_WRITE_ALLOWED_PREFIXESset the URL prefixes that CoCo can read from and write to. Thehttps://github.com/prefix covers all ofgithub.com. The GitHub App installation still limits which repositories CoCo can write to. -
Grant the
USAGEprivilege on the integration to each role whose users need to connect to GitHub. To give every user in the account access, grant it to thePUBLICrole: -
Enable the integration:
-
Verify the integration’s properties and grants:
Connect your GitHub account¶
Before you start, make sure that an administrator has
set up the GitHub integration and that your role has the USAGE privilege on
it.
To connect your GitHub account, do the following:
-
Sign in to Snowsight and open CoCo.
-
In the message box, select the project menu, and then select Git settings.
Agent settings opens on the Integrations tab. You can also open it by selecting Settings » Account » Agent settings » Integrations.
-
On the GitHub tile, select Connect. GitHub opens an authorization window for Snowflake CoCo.
-
In the authorization window, select Authorize.
After you authorize, the window closes, and CoCo can access your GitHub repositories.
Connect your GitHub account by using SQL¶
If you can’t use Snowsight, for example when you connect a service user or work from the command line, you can complete the OAuth flow with SQL instead:
-
Start the OAuth flow, specifying the name of the security integration that your administrator created:
The function returns a GitHub authorization URL.
-
Open the URL in a browser, and then select Authorize.
GitHub redirects your browser to a Snowflake callback URL. Copy the query string from the redirected URL, which is everything after the
?character. It has the formcode=<code>&iss=<issuer>&state=<state>. -
In the same session that you used in step 1, finish the OAuth flow by passing the query string:
Note
- Run both functions in the same session. If you start the flow in one session and finish it in another, the flow fails.
- The authorization code expires shortly after GitHub issues it. If
SYSTEM$FINISH_OAUTH_FLOWreports that the code is invalid or expired, start over from step 1.
Use Snowflake CLI¶
When you run these functions with the snow sql command, start an interactive session so that both functions run in the
same session. Also disable SQL templating, because Snowflake CLI otherwise interprets each &<name> in the query string
as a template variable and fails with an error such as SQL template rendering error: 'iss' is undefined:
Work with a repository¶
To work on a repository, select the project menu in the CoCo message box, and then either select a repository from the
list or paste its name in owner/repo format. Then describe the task in the message box. For example:
CoCo clones the repository into its sandbox and makes the changes. CoCo can then push a branch and open a pull request on your behalf.
Disconnect your GitHub account¶
To remove CoCo’s access to your GitHub account, open Settings » Account » Agent settings » Integrations, and then select Disconnect on the GitHub tile.
Limitations¶
During the preview, the GitHub integration has the following limitations:
- Write access depends on the GitHub App installation. CoCo can push branches and open pull requests only in repositories where the Snowflake CoCo GitHub App is installed. To give CoCo write access to more repositories, ask your GitHub organization administrator to add them to the app’s installation.
- Only GitHub is supported. The integration supports repositories on
github.com. Other Git hosts aren’t supported.
Related documentation¶
Legal notices¶
Where your configuration of Cortex Code uses a model provided on the Model and Service Pass-Through Terms, your use of that model is further subject to the terms for that model on that page.
The data classification of inputs and outputs are as set forth in the following table.
| Input data classification | Output data classification | Designation |
|---|---|---|
| Usage Data | Customer Data | Covered AI Features [1] |
For additional information, refer to Snowflake AI and ML.