-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
96 lines (89 loc) · 2.82 KB
/
action.yaml
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
name: "Defang Deployment Action"
description: "Use Defang to automatically deploy your application to the cloud."
author: "Defang"
branding:
icon: "cloud"
color: "blue"
inputs:
cli-version:
description: "The version of the Defang CLI to use."
required: false
default: ""
config-env-vars:
description: "Environment variables deploy as config. Format: 'VAR1 VAR2 VAR3'"
required: false
default: ""
cwd:
description: "The directory containing the compose file to deploy."
required: false
default: "."
compose-files:
description: "The compose files to deploy. Format 'file1 file2 file3'"
required: false
default: ""
mode:
description: "The deployment mode. Options: 'development', 'staging', 'production'"
required: false
default: ""
provider:
description: "The cloud provider to deploy to. Options: 'aws', 'defang', 'digitalocean'"
required: false
default: "defang"
command:
description: "The command to run."
required: false
default: "compose up"
runs:
using: "composite"
steps:
- name: Install defang
shell: bash
run: . <(curl -Lf https://raw.githubusercontent.com/DefangLabs/defang/main/src/bin/install || echo return $?)
env:
DEFANG_INSTALL_VERSION: ${{ inputs['cli-version'] }}
GH_TOKEN: ${{ github.token }} # avoid rate-limits
- name: Set Defang environment variables
shell: bash
run: |
echo "DEFANG_PROVIDER=${{ inputs['provider'] }}" >> $GITHUB_ENV
echo "DEFANG_DEBUG=$RUNNER_DEBUG" >> $GITHUB_ENV
- name: Login to Defang
shell: bash
run: |
defang login
defang whoami
- name: Defang Config Set
shell: bash
if: ${{ inputs['config-env-vars'] != '' }}
run: |
# Iterate over the sources and set the environment variables
params=()
for filename in ${{ inputs['compose-files'] }}; do
params+=("-f")
params+=("$filename")
done
for source in $CONFIG_ENV_VARS; do
echo "Updating $source"
echo defang config "${params[@]}" set -e $source
defang config "${params[@]}" set -e $source
done
working-directory: ${{ inputs.cwd }}
env:
CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }}
- name: Defang ${{ inputs['command'] }}
if: ${{ inputs['command'] != '' }}
shell: bash
working-directory: ${{ inputs.cwd }}
run: |
params=()
for filename in ${{ inputs['compose-files'] }}; do
params+=("-f")
params+=("$filename")
done
if [[ -n "${{ inputs['mode'] }}" ]]; then
params+=("--mode=${{ inputs['mode'] }}")
fi
echo defang $COMMAND "${params[@]}"
defang $COMMAND "${params[@]}"
env:
COMMAND: ${{ inputs['command'] }}