Skip to content

Commit

Permalink
Configure Snowflake authentication in upload-and-deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
philerooski committed Jun 26, 2024
1 parent 1deebfc commit 1d1a9fe
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/upload-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,56 @@ jobs:
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0

deploy-snowflake:
name: Deploy Snowflake resources
needs: pre-commit
runs-on: ubuntu-latest
env:
PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWFLAKE_PRIVATE_KEY_PASSPHRASE }}
steps:
- uses: actions/checkout@v3

- name: Configure Snowflake connection
run: |
# Create temporary files for config.toml and our private key
#mkdir ~/.snowflake
#config_file="~/.snowflake/config.toml"
config_file=$(mktemp)
private_key_file=$(mktemp)
# Write to the private key file
echo "${{ secrets.SNOWFLAKE_PRIVATE_KEY }}" > $private_key_file
# Write to config.toml file
echo 'default_connection_name = "recover"' >> $config_file
echo '[connections.recover]' >> $config_file
echo "account = \"${{ vars.SNOWFLAKE_ACCOUNT }}\"" >> $config_file
echo "user = \"${{ vars.SNOWFLAKE_USER }}\"" >> $config_file
echo "role = \"${{ vars.SNOWFLAKE_ROLE }}\"" >> $config_file
echo 'authenticator = "SNOWFLAKE_JWT"' >> $config_file
echo "private_key_path = \"$private_key_file\"" >> $config_file
# check config file
cat $config_file
# Write config.toml path to global environment
echo "SNOWFLAKE_CONFIG_PATH=$config_file" >> $GITHUB_ENV
- name: check config
run: |
echo $SNOWFLAKE_CONFIG_PATH
cat $SNOWFLAKE_CONFIG_PATH
- name: Install Snowflake CLI
uses: Snowflake-Labs/snowflake-cli-action@v1
with:
default-config-file-path: ${{ env.SNOWFLAKE_CONFIG_PATH }}

- name: test connection
run: |
snow --version
snow connection test
upload-files:
name: Upload files to S3 bucket in development
runs-on: ubuntu-latest
Expand Down

0 comments on commit 1d1a9fe

Please sign in to comment.