GitHub Action
Install Snowflake CLI
Note: Snowflake CLI Github Action is in Preview.
Streamlines installing and using Snowflake CLI in your CI/CD workflows. The CLI is installed in isolated way making sure it won't conflict with dependencies of your project. Automatically set up the input config file within the ~/.snowflake/ directory.
This actions enables automation of your Snowflake CLI tasks, such as deploying Native Apps or running Snowpark scripts within your Snowflake environment, etc.
The specified Snowflake CLI version. For example 2.2.0
. If not specified then latest version will be used.
Path to the configuration file (config.toml) in your repository. The path must be relative to root of repository.
To set up Snowflake credentials for a specific connection follow these steps.
-
Add
config.toml
to Your Repository:-
Create a
config.toml
file at the root of your repository with an empty connection configuration. For example:[connections] [connections.myconnection] user = "" password = ""
This file serves as a template and is preferable to not contain any actual credentials.
-
-
Store Credentials in GitHub Secrets:
- Store each credential (e.g., account, password) in GitHub Secrets. Refer to the GitHub Actions documentation for detailed instructions on how to create and manage secrets for your repository.
-
Map Secrets to Environment Variables:
-
Map each secret to an environment variable using the format
SNOWFLAKE_CONNECTIONS_<connection-name>_<key>=<value>
. This overrides the credentials defined inconfig.toml
. For example:env: SNOWFLAKE_CONNECTIONS_MYCONNECTION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} SNOWFLAKE_CONNECTIONS_MYCONNECTION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
-
-
Configure the Snowflake CLI Action:
-
Add the
default-config-file-path
parameter to the Snowflake CLI action step in your workflow file. This specifies the path to yourconfig.toml
file. For example:- uses: Snowflake-Labs/snowflake-cli-action@v1 with: cli-version: "latest" default-config-file-path: ".\config.toml"
Replace
latest
with a specific version of Snowflake CLI action if needed. -
For more information in setting Snowflake credentials using environment variables, refer to the Snowflake CLI documentation. And the instructions on defining environment variables within your Github CI/CD workflow can be found here.
default_connection_name = "myconnection"
[connections]
[connections.myconnection]
user = ""
password = ""
name: deploy
on: [push]
jobs:
version:
name: "Check Snowflake CLI version"
runs-on: ubuntu-latest
env:
SNOWFLAKE_CONNECTIONS_MYCONNECTION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_CONNECTIONS_MYCONNECTION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_CONNECTIONS_MYCONNECTION_USER: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_CONNECTIONS_MYCONNECTION_DATABASE: ${{ secrets.SNOWFLAKE_ACCOUNT }}
steps:
# Checkout step is necessary if you want to use a config file from your repo
- name: Checkout repo
uses: actions/checkout@v4
with:
persist-credentials: false
# Snowflake CLI installation
- uses: Snowflake-Labs/snowflake-cli-action@v1
with:
cli-version: "latest"
default-config-file-path: "config.toml"
# Use the CLI
- name: Test version
run: |
snow --version
snow connection test