Skip to content

Commit

Permalink
Update workflows and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
shalabhc committed Jul 28, 2023
1 parent 25fbcee commit a87b614
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
40 changes: 24 additions & 16 deletions .github/workflows/branch_deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,57 @@ name: Serverless Branch Deployments
on:
pull_request:
types: [opened, synchronize, reopened, closed]

concurrency:
# Cancel in-progress runs on same branch
group: ${{ github.ref }}
# Cancel in-progress deploys to same branch
group: ${{ github.ref }}/branch_deployments
cancel-in-progress: true
env:
DAGSTER_CLOUD_URL: ${{ secrets.DAGSTER_CLOUD_URL }}
DAGSTER_CLOUD_URL: "http://ORGANIZATION_NAME.dagster.cloud"
DAGSTER_CLOUD_API_TOKEN: ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
ENABLE_FAST_DEPLOYS: 'true'
PYTHON_VERSION: '3.8'
DAGSTER_CLOUD_FILE: 'dagster_cloud.yaml'

jobs:
dagster_cloud_default_deploy:
name: Dagster Serverless Deploy
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
outputs:
build_info: ${{ steps.parse-workspace.outputs.build_info }}

steps:
- name: Parse cloud workspace
if: env.ENABLE_FAST_DEPLOYS != 'true'
- name: Prerun Checks
id: prerun
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]

- name: Launch Docker Deploy
if: steps.prerun.outputs.result == 'docker-deploy'
id: parse-workspace
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
dagster_cloud_file: dagster_cloud.yaml
dagster_cloud_file: $DAGSTER_CLOUD_FILE

- name: Checkout
if: env.ENABLE_FAST_DEPLOYS == 'true'
- name: Checkout for Python Executable Deploy
if: steps.prerun.outputs.result == 'pex-deploy'
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
path: project-repo

- name: Build and deploy Python executable
if: env.ENABLE_FAST_DEPLOYS == 'true'
uses: dagster-io/dagster-cloud-action/actions/build_deploy_python_executable@pex-v0.1
- name: Python Executable Deploy
if: steps.prerun.outputs.result == 'pex-deploy'
uses: dagster-io/dagster-cloud-action/actions/[email protected]
with:
dagster_cloud_file: "$GITHUB_WORKSPACE/project-repo/dagster_cloud.yaml"
dagster_cloud_file: "$GITHUB_WORKSPACE/project-repo/$DAGSTER_CLOUD_FILE"
build_output_dir: "$GITHUB_WORKSPACE/build"
python_version: "3.8"
python_version: "${{ env.PYTHON_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

dagster_cloud_docker_deploy:
name: Dagster Serverless Docker Deploy
runs-on: ubuntu-latest
name: Docker Deploy
runs-on: ubuntu-20.04
if: needs.dagster_cloud_default_deploy.outputs.build_info
needs: dagster_cloud_default_deploy
strategy:
Expand All @@ -62,6 +69,7 @@ jobs:
with:
dagster_cloud_api_token: ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
location: ${{ toJson(matrix.location) }}
base_image: "python:${{ env.PYTHON_VERSION }}-slim"
# Uncomment to pass through Github Action secrets as a JSON string of key-value pairs
# env_vars: ${{ toJson(secrets) }}
organization_id: ${{ secrets.ORGANIZATION_ID }}
Expand Down
40 changes: 24 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,57 @@ on:
branches:
- "main"
- "master"

concurrency:
# Cancel in-progress deploys to main branch
group: ${{ github.ref }}
# Cancel in-progress deploys to same branch
group: ${{ github.ref }}/deploy
cancel-in-progress: true
env:
DAGSTER_CLOUD_URL: ${{ secrets.DAGSTER_CLOUD_URL }}
DAGSTER_CLOUD_URL: "http://ORGANIZATION_NAME.dagster.cloud"
DAGSTER_CLOUD_API_TOKEN: ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
ENABLE_FAST_DEPLOYS: 'true'
PYTHON_VERSION: '3.8'
DAGSTER_CLOUD_FILE: 'dagster_cloud.yaml'

jobs:
dagster_cloud_default_deploy:
name: Dagster Serverless Deploy
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
outputs:
build_info: ${{ steps.parse-workspace.outputs.build_info }}

steps:
- name: Parse cloud workspace
if: env.ENABLE_FAST_DEPLOYS != 'true'
- name: Prerun Checks
id: prerun
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]

- name: Launch Docker Deploy
if: steps.prerun.outputs.result == 'docker-deploy'
id: parse-workspace
uses: dagster-io/dagster-cloud-action/actions/utils/[email protected]
with:
dagster_cloud_file: dagster_cloud.yaml
dagster_cloud_file: $DAGSTER_CLOUD_FILE

- name: Checkout
if: env.ENABLE_FAST_DEPLOYS == 'true'
- name: Checkout for Python Executable Deploy
if: steps.prerun.outputs.result == 'pex-deploy'
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
path: project-repo

- name: Build and deploy Python executable
if: env.ENABLE_FAST_DEPLOYS == 'true'
uses: dagster-io/dagster-cloud-action/actions/build_deploy_python_executable@pex-v0.1
- name: Python Executable Deploy
if: steps.prerun.outputs.result == 'pex-deploy'
uses: dagster-io/dagster-cloud-action/actions/[email protected]
with:
dagster_cloud_file: "$GITHUB_WORKSPACE/project-repo/dagster_cloud.yaml"
dagster_cloud_file: "$GITHUB_WORKSPACE/project-repo/$DAGSTER_CLOUD_FILE"
build_output_dir: "$GITHUB_WORKSPACE/build"
python_version: "3.8"
python_version: "${{ env.PYTHON_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

dagster_cloud_docker_deploy:
name: Dagster Serverless Docker Deploy
runs-on: ubuntu-latest
name: Docker Deploy
runs-on: ubuntu-20.04
if: needs.dagster_cloud_default_deploy.outputs.build_info
needs: dagster_cloud_default_deploy
strategy:
Expand All @@ -64,6 +71,7 @@ jobs:
with:
dagster_cloud_api_token: ${{ secrets.DAGSTER_CLOUD_API_TOKEN }}
location: ${{ toJson(matrix.location) }}
base_image: "python:${{ env.PYTHON_VERSION }}-slim"
# Uncomment to pass through Github Action secrets as a JSON string of key-value pairs
# env_vars: ${{ toJson(secrets) }}
organization_id: ${{ secrets.ORGANIZATION_ID }}
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ Set up secrets on your newly created repository by navigating to the `Settings`
| Name | Description |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DAGSTER_CLOUD_API_TOKEN` | An agent token, for more details see [the Dagster Cloud docs](https://docs.dagster.cloud/auth#managing-user-and-agent-tokens). |
| `ORGANIZATION_ID` | The organization ID of your Dagster Cloud organization, found in the URL. For example, `pied-piper` if your organization is found at `https://dagster.cloud/pied-piper` or `https://pied-piper.dagster.cloud/`. |

## Update workflows

Replace the `ORGANIZATION_NAME` in both `.github/workflows/deploy.yml` and `.github/workflows/branch_deployments.yml` with your Dagster cloud organization name:

```
DAGSTER_CLOUD_URL: "http://ORGANIZATION_NAME.dagster.cloud"
```

## Verify Builds are Successful

Expand Down

0 comments on commit a87b614

Please sign in to comment.