-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from kameshsampath/main
(fix!): Refactor Enable GH Action
- Loading branch information
Showing
18 changed files
with
370 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Clean up | ||
on: | ||
workflow_dispatch: | ||
env: | ||
SNOWFLAKE_DEFAULT_CONNECTION_NAME: "workflow" | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_USER: ${{ secrets.SNOWFLAKE_USER }} | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_PRIVATE_KEY_PASSPHRASE: | ||
${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_PRIVATE_KEY_RAW: | ||
${{ secrets.PRIVATE_KEY_RAW }} | ||
GIT_REPO_DB: MY_GIT_REPOS | ||
GIT_REPO_SCHEMA: GITHUB | ||
GIT_REPO_NAME: snow_cli_demo | ||
TODO_APP_NAME: todos_app | ||
TODO_APP_WH: TODO_APP_WH | ||
TODO_APP_DB: TODO_APP_DB | ||
TODO_APP_SCHEMA: APPS | ||
TODOS_DATA_SCHEMA: DATA | ||
jobs: | ||
Deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# todo update to pick the right branch | ||
ref: ${{ env.GITHUB_REF_NAME }} | ||
- uses: Snowflake-Labs/snowflake-cli-action@v1.5 | ||
with: | ||
cli-version: "latest" | ||
default-config-file-path: | ||
${{ github.workspace }}/config/config.toml" | ||
- name: Check Version and Verify Connection | ||
env: | ||
PRIVATE_KEY_PASSPHRASE: ${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
run: | | ||
snow --version | ||
snow connection test | ||
echo "Using branch $GITHUB_REF_NAME" | ||
- name: Setup Todos App Database Objects | ||
env: | ||
PRIVATE_KEY_PASSPHRASE: ${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
GIT_REPO_FQN: | ||
${{ env.GIT_REPO_DB }}.${{ env.GIT_REPO_SCHEMA }}.${{ | ||
env.GIT_REPO_NAME }} | ||
run: | | ||
snow git execute "@$GIT_REPO_FQN/branches/$GITHUB_REF_NAME/cleanup.sql" \ | ||
--variable "db_name='$TODO_APP_DB'" \ | ||
--variable "git_repo_name='$GIT_REPO_FQN'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Deploy | ||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [published] | ||
push: | ||
paths: | ||
- "de/**" | ||
- "data/*.csv" | ||
- "app/**" | ||
env: | ||
SNOWFLAKE_DEFAULT_CONNECTION_NAME: "workflow" | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_USER: ${{ secrets.SNOWFLAKE_USER }} | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_PRIVATE_KEY_PASSPHRASE: | ||
${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
SNOWFLAKE_CONNECTIONS_WORKFLOW_PRIVATE_KEY_RAW: | ||
${{ secrets.PRIVATE_KEY_RAW }} | ||
GIT_REPO_DB: MY_GIT_REPOS | ||
GIT_REPO_SCHEMA: GITHUB | ||
GIT_REPO_NAME: snow_cli_demo | ||
TODO_APP_NAME: todos_app | ||
TODO_APP_WH: TODO_APP_WH | ||
TODO_APP_DB: TODO_APP_DB | ||
TODO_APP_SCHEMA: APPS | ||
TODOS_DATA_SCHEMA: DATA | ||
jobs: | ||
Deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# todo update to pick the right branch | ||
ref: ${{ env.GITHUB_REF_NAME }} | ||
- uses: Snowflake-Labs/snowflake-cli-action@v1.5 | ||
with: | ||
cli-version: "latest" | ||
default-config-file-path: | ||
${{ github.workspace }}/config/config.toml | ||
- name: Check Version and Verify Connection | ||
env: | ||
PRIVATE_KEY_PASSPHRASE: ${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
run: | | ||
snow --version | ||
snow connection test | ||
echo "Using branch $GITHUB_REF_NAME" | ||
- name: Refresh Repo | ||
env: | ||
PRIVATE_KEY_PASSPHRASE: ${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
GIT_REPO_FQN: | ||
${{ env.GIT_REPO_DB }}.${{ env.GIT_REPO_SCHEMA }}.${{ | ||
env.GIT_REPO_NAME }} | ||
run: | | ||
snow git fetch "$GIT_REPO_FQN" | ||
- name: Setup Todos App Database Objects | ||
env: | ||
PRIVATE_KEY_PASSPHRASE: ${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
GIT_REPO_FQN: | ||
${{ env.GIT_REPO_DB }}.${{ env.GIT_REPO_SCHEMA }}.${{ | ||
env.GIT_REPO_NAME }} | ||
run: | | ||
snow git execute @"${GIT_REPO_FQN}/branches/${GITHUB_REF_NAME}/de/" \ | ||
--variable "db_name='$TODO_APP_DB'" \ | ||
--variable "schema_name='$TODOS_DATA_SCHEMA'" \ | ||
--variable "wh_name='$TODO_APP_WH'" \ | ||
--variable "git_repo_name='$GIT_REPO_FQN'" \ | ||
--variable "git_branch='$GIT_BRANCH'" \ | ||
--database $GIT_REPO_DB --schema $GIT_REPO_SCHEMA | ||
- name: Deploy TODOs Streamlit App | ||
env: | ||
PRIVATE_KEY_PASSPHRASE: ${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
run: | | ||
snow streamlit deploy --replace \ | ||
--database $TODO_APP_DB --schema $TODO_APP_SCHEMA | ||
working-directory: app | ||
|
||
- name: Get App URL | ||
env: | ||
PRIVATE_KEY_PASSPHRASE: ${{ secrets.PRIVATE_KEY_PASSPHRASE }} | ||
run: | | ||
snow streamlit get-url $TODO_APP_NAME \ | ||
--database $TODO_APP_DB --schema $TODO_APP_SCHEMA | ||
working-directory: app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python 3.11.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
.venv/ | ||
app.zip | ||
__pycache__ | ||
TODO.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
--!jinja | ||
USE ROLE ACCOUNTADMIN; | ||
|
||
DROP DATABASE IF EXISTS {{db_name}}; | ||
DROP DATABASE IF EXISTS {{db_name}}; | ||
|
||
DROP GIT REPOSITORY IF EXISTS {{git_repo_name}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
default_connection_name = "workflow" | ||
|
||
[connections] | ||
[connections.workflow] | ||
authenticator="SNOWFLAKE_JWT" |
File renamed without changes.
Oops, something went wrong.