forked from PrefectHQ/actions-prefect-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
85 lines (77 loc) · 2.66 KB
/
action.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
79
80
81
82
83
84
85
name: Deploy a Prefect flow
author: PrefectHQ
description: Deploy a flow from a project by creating a Prefect deployment.
branding:
icon: upload-cloud
color: blue
inputs:
deployment-names:
description:
Comma separated list of names of your
Prefect deployments.
example 'deployment1,deployment2'
required: false
default: deployment
requirements-file-paths:
description:
Comma separated list of paths to
requirements files to correctly install
dependencies for your Prefect flow(s).
example './flow1/requirements.txt,./flow2/requirements.txt'
required: false
default: ''
deployment-file-path:
description:
Relative path to your Prefect deployment file.
example './prefect-deployment-files/prefect.yaml'
required: false
default: './prefect.yaml'
pyproject-toml-path:
description:
Path to your pyproject.toml file for
dependency management of your Prefect flow(s).
example './pyproject.toml'
required: false
default: ''
all-deployments:
description:
If set to true, all deployments will be
deployed. This will override the
deployment-names input.
default: "false"
runs:
using: composite
steps:
- id: install-local-requirements
if: ${{ inputs.requirements-file-paths != '' }}
run: |
IFS=',' read -ra requirements_paths <<< "${{ inputs.requirements-file-paths }}"
for req in ${requirements_paths[@]}; do
pip install -r $req
done
shell: bash
- id: install-from-pyproject-toml
if: ${{ inputs.pyproject-toml-path != '' }}
run: |
cd $(dirname ${{ inputs.pyproject-toml-path }})
pip install .
shell: bash
- id: prefect-deploy
run: |
PREFECT_VERSION=$(prefect --version)
PREFECT_SHORT_VERSION="$(cut -d "." -f 2 <<< "$PREFECT_VERSION")"."$(cut -d "." -f 3 <<< "$PREFECT_VERSION")"
if [ $(echo $PREFECT_SHORT_VERSION'<'10.14 | bc -l) -eq 1 ];
then
echo "The currently installed Prefect version (2.$PREFECT_SHORT_VERSION) will be updated to the latest to ensure compatibility with this action."
pip install prefect -U "prefect>=2.10.14"
fi
if [ ${{ inputs.all-deployments }} == "true" ];
then
prefect --no-prompt deploy --all --prefect-file "${{ inputs.deployment-file-path }}"
else
IFS=',' read -ra deployment_names <<< "${{ inputs.deployment-names }}"
for name in "${deployment_names[@]}"; do
prefect --no-prompt deploy --prefect-file "${{ inputs.deployment-file-path }}" --name "$name"
done
fi
shell: bash