1
- name : Serverless Prod Deployment
1
+ name : Serverless Deployment
2
2
on :
3
3
push :
4
4
branches :
5
5
- " main"
6
6
- " master"
7
-
7
+ pull_request :
8
+ types : [opened, synchronize, reopened, closed]
9
+
8
10
concurrency :
9
11
# Cancel in-progress deploys to same branch
10
12
group : ${{ github.ref }}/deploy
@@ -14,67 +16,100 @@ env:
14
16
DAGSTER_CLOUD_API_TOKEN : ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
15
17
ENABLE_FAST_DEPLOYS : ' true'
16
18
PYTHON_VERSION : ' 3.8'
19
+ DAGSTER_PROJECT_DIR : ' .'
17
20
DAGSTER_CLOUD_FILE : ' dagster_cloud.yaml'
21
+ DAGSTER_CLOUD_ORGANIZATION : ${{ secrets.DAGSTER_CLOUD_ORGANIZATION }}
22
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
18
23
19
24
jobs :
20
25
dagster_cloud_default_deploy :
21
26
name : Dagster Serverless Deploy
22
27
runs-on : ubuntu-20.04
23
- outputs :
24
- build_info : ${{ steps.parse-workspace.outputs.build_info }}
25
-
28
+
26
29
steps :
27
30
- name : Prerun Checks
28
31
id : prerun
29
32
uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
30
33
31
- - name : Launch Docker Deploy
32
- if : steps.prerun.outputs.result == 'docker-deploy'
33
- id : parse-workspace
34
- uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
35
- with :
36
- dagster_cloud_file : $DAGSTER_CLOUD_FILE
37
-
38
- - name : Checkout for Python Executable Deploy
39
- if : steps.prerun.outputs.result == 'pex-deploy'
34
+ - name : Checkout
40
35
uses : actions/checkout@v3
41
36
with :
42
37
ref : ${{ github.head_ref }}
43
- path : project-repo
44
-
45
- - name : Python Executable Deploy
38
+
39
+ # Validate dagster_cloud.yaml and the connection to dagster.cloud
40
+ - name : Validate configuration
41
+ id : ci-validate
42
+ if : steps.prerun.outputs.result != 'skip'
43
+ uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
44
+ with :
45
+ command : " ci check --project-dir ${{ env.DAGSTER_PROJECT_DIR }} --dagster-cloud-yaml-path ${{ env.DAGSTER_CLOUD_FILE }}"
46
+
47
+ # Parse dagster_cloud.yaml, detect if this is branch deployment and initialize the build session
48
+ - name : Initialize build session
49
+ id : ci-init
50
+ uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
51
+ with :
52
+ project_dir : ${{ env.DAGSTER_PROJECT_DIR }}
53
+ dagster_cloud_yaml_path : ${{ env.DAGSTER_CLOUD_FILE }}
54
+ # The full deployment name. If this run is for a PR, this value is ignored and a branch
55
+ # deployment is used.
56
+ deployment : ' prod'
57
+
58
+
59
+ # If using fast build, build the PEX
60
+ # First ensure the correct Python version is installed
61
+ - name : Set up Python ${{ env.PYTHON_VERSION }} for target
62
+ id : custom-python-version
63
+ if : steps.pre-run.outputs.result == 'pex-deploy' && ${{ env.PYTHON_VERSION != '3.8' }}
64
+ uses : actions/setup-python@v5
65
+ with :
66
+ python-version : ${{ env.PYTHON_VERSION }}
67
+ - name : Install setuptools
68
+ if : steps.pre-run.outputs.result == 'pex-deploy' && ${{ env.PYTHON_VERSION != '3.8' }}
69
+ run : ${{ steps.custom-python-version.outputs.python-path }} -m pip install setuptools
70
+ shell : bash
71
+
72
+ - name : Run PEX build
73
+ id : run-pex-build
46
74
if : steps.prerun.outputs.result == 'pex-deploy'
47
- uses : dagster-io/dagster-cloud-action/actions/build_deploy_python_executable @v0.1
75
+ uses : dagster-io/dagster-cloud-action/actions/utils/dagster-cloud-cli @v0.1
48
76
with :
49
- dagster_cloud_file : " $GITHUB_WORKSPACE/project-repo/$DAGSTER_CLOUD_FILE"
50
- build_output_dir : " $GITHUB_WORKSPACE/build"
51
- python_version : " ${{ env.PYTHON_VERSION }}"
52
- env :
53
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54
-
55
- dagster_cloud_docker_deploy :
56
- name : Docker Deploy
57
- runs-on : ubuntu-20.04
58
- if : needs.dagster_cloud_default_deploy.outputs.build_info
59
- needs : dagster_cloud_default_deploy
60
- strategy :
61
- fail-fast : false
62
- matrix :
63
- location : ${{ fromJSON(needs.dagster_cloud_default_deploy.outputs.build_info) }}
64
- steps :
65
- - name : Checkout
66
- uses : actions/checkout@v3
77
+ command : " ci build --build-strategy=python-executable --python-version ${{ env.PYTHON_VERSION }} --pex-deps-cache-from='${{ github.repository }}' --pex-deps-cache-to='${{ github.repository }}'"
78
+
79
+
80
+ # Otherwise, enable buildx for caching and build the Docker image
81
+ - name : Set up Docker Buildx
82
+ if : steps.prerun.outputs.result == 'docker-deploy'
83
+ uses : docker/setup-buildx-action@v2
84
+
85
+ - name : Run Docker build
86
+ id : run-docker-build
87
+ if : steps.prerun.outputs.result == 'docker-deploy'
88
+ uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
67
89
with :
68
- ref : ${{ github.head_ref }}
69
- - name : Build and deploy to Dagster Cloud serverless
70
- uses :
dagster-io/dagster-cloud-action/actions/[email protected]
90
+ command : " ci build --build-strategy=docker --python-version ${{ env.PYTHON_VERSION }}"
91
+
92
+
93
+ # Deploy all code locations in this build session to Dagster Cloud
94
+ - name : Deploy to Dagster Cloud
95
+ id : ci-deploy
96
+ if : steps.prerun.outputs.result != 'skip'
97
+ uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
71
98
with :
72
- dagster_cloud_api_token : ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
73
- location : ${{ toJson(matrix.location) }}
74
- base_image : " python:${{ env.PYTHON_VERSION }}-slim"
75
- # Uncomment to pass through Github Action secrets as a JSON string of key-value pairs
76
- # env_vars: ${{ toJson(secrets) }}
77
- organization_id : ${{ secrets.ORGANIZATION_ID }}
78
- env :
79
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
99
+ command : " ci deploy"
80
100
101
+ # Update a PR comment - this runs always() so the comment is updated on success and failure
102
+ - name : Update PR comment for branch deployments
103
+ id : ci-notify
104
+ if : steps.prerun.outputs.result != 'skip'
105
+ uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
106
+ with :
107
+ command : " ci notify --project-dir=${{ env.DAGSTER_PROJECT_DIR }}"
108
+
109
+ # Generate a summary that shows up on the Workflow Summary page
110
+ - name : Generate a summary
111
+ id : ci-summary
112
+ if : steps.prerun.outputs.result != 'skip'
113
+ uses :
dagster-io/dagster-cloud-action/actions/utils/[email protected]
114
+ with :
115
+ command : " ci status --output-format=markdown >> $GITHUB_STEP_SUMMARY"
0 commit comments