-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (75 loc) · 2.7 KB
/
deploy_ml.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: deploy-ml
on:
push:
branches: [main]
jobs:
get-latest-tag:
runs-on: ubuntu-latest
outputs:
latest-tag: ${{ steps.latest-tag.outputs.tag }}
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0 # fetch the whole repo history
- name: Get latest git tag
id: latest-tag
run: |
latest_tag='0.0.0'
for ref in $(git for-each-ref --sort=-creatordate --format '%(refname)' refs/tags); do
tag="${ref#refs/tags/}"
echo "forloop"
echo $tag
if echo "${tag}" | grep -Eq '^v?([0-9]+)\.([0-9]+)\.([0-9]+)(?-([0-9A-Za-z-]+(?\.[0-9A-Za-z-]+)*))?(?\+[0-9A-Za-z-]+)?$'; then
latest_tag="${tag}"
echo $tag
echo "passed regex"
break
fi
done
echo "::set-output name=tag::${latest_tag}"
- name: Print latest tag
run: echo "${{ steps.latest-tag.outputs.tag }}"
deploy-udf:
runs-on: ubuntu-latest
needs: get-latest-tag
env:
POETRY_VERSION: 1.1.12
SNOWSQL_PRIVATE_KEY_PATH: ${{ github.workspace }}/snowflake.p8
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies and build package
run: |
pip install poetry==${{ env.POETRY_VERSION }}
poetry version ${{ needs.get-latest-tag.outputs.latest-tag }}
poetry version minor
poetry config virtualenvs.create false
poetry install --no-interaction --no-ansi
poetry build --format wheel
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "NEW_TAG=$(poetry version --short)" >> $GITHUB_ENV
- name: Set Snowflake key file
run: |
echo "${{ secrets.SNOWSQL_PRIVATE_KEY }}" > ${{ env.SNOWSQL_PRIVATE_KEY_PATH }}
- name: Create inference UDF
env:
SNOWSQL_PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWSQL_PRIVATE_KEY_PASSPHRASE }}
SNOWSQL_PRIVATE_KEY_FILEPATH: ${{ env.SNOWSQL_PRIVATE_KEY_PATH }}
ENVIRONMENT: PROD
run: |
python scripts/create_inference_udf.py
- name: Tag
uses: actions/github-script@v5
with:
github-token: ${{ github.token }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.NEW_TAG }}",
sha: context.sha
})