forked from astronomer/deploy-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
106 lines (97 loc) · 3.36 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: "Deploy Airflow code to an Astro Cloud Deployment"
description: "Deploys your Astro Airflow project to an Astro Cloud Deployment. Works with DAG-Only Deploys enabled or disabled."
branding:
icon: 'upload-cloud'
color: 'purple'
inputs:
dag-deploy-enabled:
required: false
default: false
description: "If true only DAGs will be deployed when dag files are pushed."
root-folder:
required: false
default: ./
description: "Path to to Astro project folder that contains that 'dags' folder"
parse:
required: false
default: false
description: "If true DAGs will be parsed before deploying to Astro."
pytest:
required: false
default: false
description: "if true custom Pytests will be ran before deploying to Astro."
pytest-file:
required: false
description: "Specify custom Pytest files to run with the pytest command."
force:
required: false
default: false
description: "If true your code will be force deployedto Astornomer. Mostly uesd to skip parse test on image deploys."
image-name:
required: false
default: no-custom-image
description: Specify a custom built image to deploy to an Asto Deployment.
runs:
using: "composite"
steps:
- name: checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 2
# Determine if only DAGs have changes
- name: Get Deployment Type
run: |
cd ${{ inputs.root-folder }}
files=$(git diff --name-only HEAD^..HEAD)
dags_only=1
for file in $files; do
if [[ $file != *"dags/"* ]]; then
echo $file is not a dag, triggering a full image build
dags_only=0
break
fi
done
if [[ ${{ inputs.dag-deploy-enabled }} == false ]]; then
dags_only=0
fi
echo "DAGS_ONLY=$dags_only" >> $GITHUB_OUTPUT
shell: bash
id: deployment-type
# If only DAGs changed and dag deploys is enabled, do a DAG-only deploy
- name: setup deploy options
run: |
options=""
# add parse option
if [[ ${{ inputs.parse }} == true ]]; then
options="--parse"
fi
# add pytest option
if [[ ${{ inputs.pytest }} == true ]]; then
options="$options --pytest --test ${{ inputs.pytest-file }}"
fi
# add custom image option
if [[ ${{ inputs.image-name }} != no-custom-image ]]; then
options="$options --image-name ${{ inputs.image-name }}"
fi
# add force option
if [[ ${{ inputs.force }} == true ]]; then
options="$options --force"
fi
echo "OPTIONS=$options" >> $GITHUB_OUTPUT
shell: bash
id: deploy-options
- name: DAG Deploy to Astro
if: steps.deployment-type.outputs.DAGS_ONLY == 1
run: |
cd ${{ inputs.root-folder }}
curl -sSL https://install.astronomer.io | sudo bash -s
astro deploy --dags ${{steps.deploy-options.outputs.OPTIONS}}
shell: bash
# If any other files changed or dag deploys is disabled, deploy the entire Astro project
- name: Image and DAG Deploy to Astro
if: steps.deployment-type.outputs.DAGS_ONLY == 0
run: |
cd ${{ inputs.root-folder }}
curl -sSL https://install.astronomer.io | sudo bash -s
astro deploy ${{steps.deploy-options.outputs.OPTIONS}}
shell: bash