This composite action leverage the sf_git package to push your tracked worksheets to your Snowflake account(s).
What you need to set up smooth synchronization between your GitHub repository and your Snowflake account:
- A snowflake account with password authentication
- Account and authentication parameters set in your GitHub repository secrets
- Worksheets previously fetched with the sf_git CLI. This action uses the metadata created by this package.
In your GitHub repository secrets, set all three variables:
- ACTIONS_SF_ACCOUNTS
- ACTION_SF_USERNAMES
- ACTION_SF_PASSWORDS
To push to several accounts, simply set the secrets to comma separated values while keep a consistency with the order.
Exemple:
ACTIONS_SF_ACCOUNTS: myaccount1.eu-west-1.aws, myaccount2.east-us-2.azure
ACTIONS_SF_USERNAME: John, Linda
ACTIONS_SF_PASSWORDS: johnSuperPassword, lindas_big_secret
Warning
The account ID to be configured is in the <account_name>.<region>.<cloud> format.
If you are unsure about how to retrieve it for your snowflake account, you can run this query:
SHOW REGIONS;
WITH
SF_REGIONS AS (SELECT * FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))),
INFOS AS (SELECT CURRENT_REGION() AS CR, CURRENT_ACCOUNT() AS CA)
SELECT CONCAT(
LOWER(INFOS.CA),
'.',
SF_REGIONS."region",
'.',
SF_REGIONS."cloud"
) AS account_id
FROM INFOS LEFT JOIN SF_REGIONS ON INFOS.CR = SF_REGIONS."snowflake_region";
Unfortunately, the region is not always the same in the SHOW REGIONS ouput. Please check and adapt the format comforming to the official documentation. For example, eastus2 for Azure should actually be east-us-2.
For more details, please refer to the related documentation in sf_git README.
Add the following step to your .github/workflows yaml files:
jobs:
push-to-sf:
runs-on: ubuntu-latest
- name: Push to snowflake
id: push_sf
uses: tdambrin/sf-push@v2
env:
ACTION_SF_ACCOUNTS: ${{ secrets.ACTION_SF_ACCOUNTS }}
ACTION_SF_USERNAMES: ${{ secrets.ACTION_SF_USERNAMES }}
ACTION_SF_PASSWORDS: ${{ secrets.ACTION_SF_PASSWORDS }}
with:
worksheets_path: demo/worksheets/
- name: Print result
run: |
echo "${{ steps.push_sf.outputs.upload_report }}"
Note
Make sure to replace your worksheets_path with the relative location (from root) where your worksheets are stored within your repository.
Feedbacks and contributions are greatly appreciated. This GitHub Action was made to ease every day life for Snowflake developers and promote version control as much as possible.
For questions, please feel free to reach out by email.