deploy udf test #8
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
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: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v37 | |
- name: Deploy to Snowflake | |
run: | | |
cd src | |
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 snowdev deploy --task $component_name || continue | |
;; | |
streamlit) | |
poetry run snowdev deploy --streamlit $component_name || continue | |
;; | |
udf) | |
poetry run snowdev deploy --udf $component_name || continue | |
;; | |
sproc) | |
poetry run snowdev deploy --sproc $component_name || continue | |
;; | |
esac | |
done | |
continue-on-error: true |