Skip to content

deploy udf

deploy udf #14

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: |
cd src
IFS=$'\n'
error_occurred=false
for dir in $(find . -mindepth 2 -type d); do # Changed this line
# Extract the path relative to src
rel_path="${dir#.}" # Changed this line
component_type=$(echo $rel_path | cut -d'/' -f2) # Adjusted field number
component_name=$(echo $rel_path | cut -d'/' -f3) # Adjusted field number
echo "Component Type: $component_type"
echo "Component Name: $component_name"
case $component_type in
task)
poetry run snowdev deploy --task $component_name || error_occurred=true
;;
streamlit)
poetry run snowdev deploy --streamlit $component_name || error_occurred=true
;;
udf)
poetry run snowdev deploy --udf $component_name || error_occurred=true
;;
sproc)
poetry run snowdev deploy --sproc $component_name || error_occurred=true
;;
esac
done
# If any deployment failed, exit the script with a non-zero status
if [ "$error_occurred" = true ]; then
exit 1
fi