Skip to content

Commit deeb0ff

Browse files
committed
Update serverless workflow template
1 parent 301b494 commit deeb0ff

File tree

2 files changed

+82
-125
lines changed

2 files changed

+82
-125
lines changed

github/serverless/branch_deployments.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

github/serverless/deploy.yml

Lines changed: 82 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
name: Serverless Prod Deployment
1+
name: Serverless Deployment
22
on:
33
push:
44
branches:
55
- "main"
66
- "master"
7-
7+
pull_request:
8+
types: [opened, synchronize, reopened, closed]
9+
810
concurrency:
911
# Cancel in-progress deploys to same branch
1012
group: ${{ github.ref }}/deploy
@@ -14,67 +16,100 @@ env:
1416
DAGSTER_CLOUD_API_TOKEN: ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
1517
ENABLE_FAST_DEPLOYS: 'true'
1618
PYTHON_VERSION: '3.8'
19+
DAGSTER_PROJECT_DIR: '.'
1720
DAGSTER_CLOUD_FILE: 'dagster_cloud.yaml'
21+
DAGSTER_CLOUD_ORGANIZATION: ${{ secrets.DAGSTER_CLOUD_ORGANIZATION }}
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1823

1924
jobs:
2025
dagster_cloud_default_deploy:
2126
name: Dagster Serverless Deploy
2227
runs-on: ubuntu-20.04
23-
outputs:
24-
build_info: ${{ steps.parse-workspace.outputs.build_info }}
25-
28+
2629
steps:
2730
- name: Prerun Checks
2831
id: prerun
2932
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
3033

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
4035
uses: actions/checkout@v3
4136
with:
4237
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
4674
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
4876
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]
6789
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]
7198
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"
80100

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

Comments
 (0)