Skip to content

Commit

Permalink
[wip] cleanup for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
benpankow committed Jul 15, 2024
1 parent 631edc8 commit f8453cd
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 560 deletions.
128 changes: 100 additions & 28 deletions .github/workflows/serverless_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,115 @@
name: Serverless Prod Deploy
name: Serverless Deployment (PEX)
on:
push:
branches:
- "main"
- "master"
pull_request:
types: [opened, synchronize, reopened, closed]

concurrency:
# Cancel in-progress deploys to same branch
group: ${{ github.ref }}/serverless-deploy
cancel-in-progress: true
env:
DAGSTER_CLOUD_URL: ${{ secrets.DAGSTER_CLOUD_SERVERLESS_URL }}
DAGSTER_CLOUD_API_TOKEN: ${{ secrets.DAGSTER_CLOUD_SERVERLESS_API_TOKEN }}
ENABLE_FAST_DEPLOYS: 'true'
PYTHON_VERSION: '3.8'
DAGSTER_PROJECT_DIR: '.'
DAGSTER_CLOUD_FILE: 'sample-repo/dagster_cloud.yaml'
DAGSTER_CLOUD_ORGANIZATION: dagster-cloud-action-github-workflow-serverless
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
parse_workspace:
runs-on: ubuntu-latest
outputs:
build_info: ${{ steps.parse-workspace.outputs.build_info }}
steps:
- uses: actions/checkout@v3
- name: Parse cloud workspace
id: parse-workspace
uses: ./actions/utils/parse_workspace
with:
dagster_cloud_file: sample-repo/dagster_cloud.yaml

dagster_cloud_build_push:
runs-on: ubuntu-latest
needs: parse_workspace
dagster_cloud_default_deploy:
name: Dagster Serverless Deploy
strategy:
fail-fast: false
matrix:
location: ${{ fromJSON(needs.parse_workspace.outputs.build_info) }}
runs-on: ubuntu-20.04

steps:
- name: Prerun Checks
id: prerun
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]

- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Build and deploy to Dagster Cloud serverless
uses: ./actions/serverless_prod_deploy
with:
dagster_cloud_api_token: ${{ secrets.DAGSTER_CLOUD_SERVERLESS_API_TOKEN }}
location: ${{ toJson(matrix.location) }}
env_vars: ${{ toJson(secrets) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Validate dagster_cloud.yaml and the connection to dagster.cloud
- name: Validate configuration
id: ci-validate
if: steps.prerun.outputs.result != 'skip'
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
command: "ci check --project-dir ${{ env.DAGSTER_PROJECT_DIR }} --dagster-cloud-yaml-path ${{ env.DAGSTER_CLOUD_FILE }}"

# Parse dagster_cloud.yaml, detect if this is branch deployment and initialize the build session
- name: Initialize build session
id: ci-init
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
project_dir: ${{ env.DAGSTER_PROJECT_DIR }}
dagster_cloud_yaml_path: ${{ env.DAGSTER_CLOUD_FILE }}
# The full deployment name. If this run is for a PR, this value is ignored and a branch
# deployment is used.
deployment: 'prod'


# If using fast build, build the PEX
# First ensure the correct Python version is installed
- name: Set up Python ${{ env.PYTHON_VERSION }} for target
id: custom-python-version
if: steps.pre-run.outputs.result == 'pex-deploy' && ${{ env.PYTHON_VERSION != '3.8' }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install setuptools
if: steps.pre-run.outputs.result == 'pex-deploy' && ${{ env.PYTHON_VERSION != '3.8' }}
run: ${{ steps.custom-python-version.outputs.python-path }} -m pip install setuptools
shell: bash

- name: Run PEX build
id: run-pex-build
if: steps.prerun.outputs.result == 'pex-deploy'
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
command: "ci build --build-strategy=python-executable --python-version ${{ env.PYTHON_VERSION }} --pex-deps-cache-from='${{ github.repository }}' --pex-deps-cache-to='${{ github.repository }}'"


# Otherwise, enable buildx for caching and build the Docker image
- name: Set up Docker Buildx
if: steps.prerun.outputs.result == 'docker-deploy'
uses: docker/setup-buildx-action@v2

- name: Run Docker build
id: run-docker-build
if: steps.prerun.outputs.result == 'docker-deploy'
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
command: "ci build --build-strategy=docker --python-version ${{ env.PYTHON_VERSION }}"


# Deploy all code locations in this build session to Dagster Cloud
- name: Deploy to Dagster Cloud
id: ci-deploy
if: steps.prerun.outputs.result != 'skip'
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
command: "ci deploy"

# Update a PR comment - this runs always() so the comment is updated on success and failure
- name: Update PR comment for branch deployments
id: ci-notify
if: steps.prerun.outputs.result != 'skip'
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
command: "ci notify --project-dir=${{ env.DAGSTER_PROJECT_DIR }}"

# Generate a summary that shows up on the Workflow Summary page
- name: Generate a summary
id: ci-summary
if: steps.prerun.outputs.result != 'skip'
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
command: "ci status --output-format=markdown >> $GITHUB_STEP_SUMMARY"
88 changes: 0 additions & 88 deletions actions/build_deploy_python_executable/action.yml

This file was deleted.

107 changes: 0 additions & 107 deletions actions/hybrid_branch_deploy/action.yml

This file was deleted.

Loading

0 comments on commit f8453cd

Please sign in to comment.