-
Notifications
You must be signed in to change notification settings - Fork 20
/
action.yml
103 lines (94 loc) · 3.99 KB
/
action.yml
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
name: "Dagster Serverless Prod Deploy"
description: "Pushes code locations to Dagster Cloud serverless prod deployment"
inputs:
organization_id:
description: "Dagster Cloud organization ID"
required: true
dagster_cloud_api_token:
description: "Dagster Cloud API token"
required: true
location:
required: true
description: 'The code location to deploy. A JSON string consisting of keys "name", "directory", "registry", "location_file".'
env_vars:
required: false
description: "A JSON string of environment variables to store in the deployed code location image."
base_image:
required: false
description: "A string of the base image name for the deployed code location image."
deployment:
required: false
description: "The deployment to push to, defaults to 'prod'."
default: "prod"
checkout_repo:
required: false
description: "Whether to start the action by checking out the repository. Set to false if your workflow modifies the file structure before deploying."
default: 'true'
runs:
using: "composite"
steps:
- name: Checkout target repo
if: inputs.checkout_repo == 'true'
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Checkout action repo
uses: actions/checkout@v4
with:
repository: dagster-io/dagster-cloud-action
ref: ${{ env.DAGSTER_ACTION_REF }}
path: ./action-repo/
env:
# We need to make sure we are grabbing the right ref for both external invocation of the
# actions (std) as well as internal invocations of the actions (internal tests).
# We need to get the local action ref, but this is available in the evaluation of `env`, not
# during the run time evaluation or the parameter evaluation:
# https://github.com/orgs/community/discussions/25283
DAGSTER_ACTION_REF: ${{ github.repository != 'dagster-io/dagster-cloud-action' && github.action_ref || github.head_ref }}
- name: Get serverless organization info
uses: ./action-repo/actions/utils/registry_info
with:
organization_id: ${{ inputs.organization_id }}
deployment: ${{ inputs.deployment }}
env:
DAGSTER_CLOUD_API_TOKEN: ${{ inputs.dagster_cloud_api_token }}
- name: Login to ECR
run: echo "${{ env.AWS_ECR_PASSWORD }}" | docker login --username ${{ env.AWS_ECR_USERNAME }} --password-stdin ${{ env.REGISTRY_URL }}
shell: bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Copy user code template file
uses: ./action-repo/actions/utils/copy_template
with:
target_directory: ${{ fromJson(inputs.location).directory }}
env_vars: ${{ inputs.env_vars }}
base_image: ${{ inputs.base_image }}
- name: generate short github sha
shell: bash
id: generate-short-sha
run: |
SHA="${{ github.sha }}"
echo SHORT_SHA=${SHA:0:7} >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
ssh: ${{ env.DOCKER_BUILD_SSH }}
context: ${{ fromJson(inputs.location).directory }}
push: true
tags: "${{ env.REGISTRY_URL }}:${{ inputs.deployment }}-${{ fromJson(inputs.location).name }}-${{ env.SHORT_SHA }}-${{ github.run_id }}-${{ github.run_attempt }}"
labels: |
branch=${{ github.head_ref }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy to Dagster Cloud
uses: ./action-repo/actions/utils/deploy
id: deploy
with:
organization_id: ${{ inputs.organization_id }}
deployment: ${{ inputs.deployment }}
pr: "${{ github.event.number }}"
location: ${{ inputs.location }}
image_tag: ${{ inputs.deployment }}-${{ fromJson(inputs.location).name }}-${{ env.SHORT_SHA }}-${{ github.run_id }}-${{ github.run_attempt }}
registry: ${{ env.REGISTRY_URL }}
env:
DAGSTER_CLOUD_API_TOKEN: ${{ inputs.dagster_cloud_api_token }}