Skip to content

deploy udf test

deploy udf test #9

name: Deploy to Snowflake
on:
push:
branches:
- prod
paths:
- "src/**"
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
env:
ACCOUNT: ${{ vars.SNOWFLAKE_ACCOUNT }}
USER_NAME: ${{ vars.SNOWFLAKE_USER }}
PASSWORD: ${{ secrets.SNOWFLAKE_PWD }}
ROLE: ${{ vars.SNOWFLAKE_ROLE }}
DATABASE: ${{ vars.SNOWFLAKE_DATABASE }}
SCHEMA: ${{ vars.SNOWFLAKE_SCHEMA }}
WAREHOUSE: ${{ vars.SNOWFLAKE_WAREHOUSE }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install
- name: Build
run: |
poetry build
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37
- name: Deploy to Snowflake
run: |
IFS=$'\n'
for file in ${{ steps.changed-files.outputs.all_modified_files }}; do
# Extract the path relative to src
rel_path="${file#src/}"
component_type=$(echo $rel_path | cut -d'/' -f1)
component_name=$(echo $rel_path | cut -d'/' -f2)
echo "Component Type: $component_type"
echo "Component Name: $component_name"
case $component_type in
task)
poetry run dist/snowdev deploy --task $component_name || continue
;;
streamlit)
poetry run dist/snowdev deploy --streamlit $component_name || continue
;;
udf)
poetry run dist/snowdev deploy --udf $component_name || continue
;;
sproc)
poetry run dist/snowdev deploy --sproc $component_name || continue
;;
esac
done
continue-on-error: true