-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yaml
224 lines (209 loc) · 9.38 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: 'Deploy Docker to Azure VM'
description: 'Deploy a Docker app to an Azure VM with Docker Compose'
branding:
icon: upload-cloud
color: red
inputs:
# Azure
AZURE_ARM_CLIENT_ID:
description: 'Azure client ID'
required: true
AZURE_ARM_CLIENT_SECRET:
description: 'Azure client secret'
required: true
AZURE_ARM_SUBSCRIPTION_ID:
description: 'Azure subscription ID'
required: true
AZURE_ARM_TENANT_ID:
description: 'Azure tenant ID'
required: true
AZURE_DEFAULT_REGION:
description: 'Azure default region'
required: true
default: 'eastus'
AZURE_STORAGE_ACCOUNT:
description: 'Azure storage account name'
required: true
default: 'bitops'
AZURE_STORAGE_SKU:
description: 'Azure storage account SKU'
required: true
default: 'Standard_LRS'
# TODO: Support Bastion
# Azure Bastion Service enables you to securely and seamlessly RDP & SSH to your VMs in your Azure virtual network, without exposing a public
# IP on the VM, directly from the Azure portal, without the need of any additional client/agent or any piece of software.
# For remote connectivity:
# TODO: Port prerequisite not met. Add an inbound network security group rule with destination port 22.
# Terraform
tf_state_bucket:
description: 'Backend Bucket to use for Terraform state. Defaults to `${org}-${repo}-{branch}-tf-state`'
required: true
tf_state_bucket_destroy:
description: 'Force purge and deletion of bucket on destroy. Any file contained there will be destroyed. `stack_destroy` must also be `true`'
required: false
default: 'true'
azure_resource_identifier:
description: 'Set to override the Azure resource identifier for the deployment. Defaults to `${org}-{repo}-{branch}`. Use with destroy to destroy specific resources.'
required: true
azure_vm_admin_username:
description: 'Set to override the Azure VM username for the deployment. Defaults to `ubuntu`.'
required: true
default: 'ubuntu'
azure_vm_admin_password:
description: 'Set to override the Azure VM password for the deployment. Defaults to `insecurePasswordABC123@`. Prefer GH Secrets.'
required: true
default: 'insecurePasswordABC123@'
# Application
docker_full_cleanup:
description: 'Set to true to run docker-compose down and docker system prune --all --force --volumes after.'
required: false
app_directory:
description: 'Relative path for the directory of the app (i.e. where `Dockerfile` and `docker-compose.yaml` files are located). This is the directory that is copied to the EC2 instance. Default is the root of the repo. Add a .gha-ignore file with a list of files to be exluded.'
app_directory_cleanup:
description: 'Will generate a timestamped compressed file and delete the app repo directory.'
required: false
app_port:
description: 'Port to expose for the app'
required: false
lb_port:
description: 'Load balancer listening port. Defaults to 80 if NO FQDN provided, 443 if FQDN provided'
required: false
lb_healthcheck:
description: 'Load balancer health check string. Defaults to HTTP:app_port'
required: false
# Stack management
stack_destroy:
description: 'Set to "true" to Destroy the stack. Will delete the elb_logs bucket after the destroy action runs.'
required: false
default: 'false'
# Domains
domain_name:
description: 'Define the root domain name for the application. e.g. app.com'
required: false
sub_domain:
description: 'Define the sub-domain part of the URL. Defaults to `${org}-${repo}-{branch}`'
root_domain:
description: 'Deploy to root domain. Will generate two DNS recrods, one for root, another for www'
required: false
cert_arn:
description: 'Define the certificate ARN to use for the application'
required: false
create_root_cert:
description: 'Generates and manage the root cert for the application'
required: false
create_sub_cert:
description: 'Generates and manage the sub-domain certificate for the application'
required: false
no_cert:
description: 'Makes the application not to use a certificate by disabling certificate lookup.'
required: false
# Terraform
targets:
description: 'A list of targets to create before the full stack creation. Example: `'
additional_tags:
description: 'A JSON object of additional tags that will be included on created resources. Example: `{"key1": "value1", "key2": "value2"}`'
required: false
# Ansible
application_mount_target:
description: "Directory path in application env to mount directory, default is `data`"
default: data
data_mount_target:
description: "Directory path within docker env to mount directory to, default is `/data`"
# efs_mount_target:
# description: "Directory path in efs to mount directory to, default is `/`"
# BitOps
DEBUG_MODE:
description: 'Set to "true" to enable debug mode'
required: false
default: 'false'
BITOPS_IMAGE:
description: 'Set to override the BitOps image to use for the deployment. Defaults to `bitovi/bitops:latest`.'
required: false
default: 'bitovi/bitops:latest'
outputs:
vm_url:
description: "The URL of the generated app"
value: ${{ steps.deploy.outputs.vm_url }}
runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Deploy with BitOps
id: deploy
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
BITOPS_ENVIRONMENT: deployment
TERRAFORM_TARGETS: ${{ inputs.targets }}
ARM_CLIENT_ID: ${{ inputs.AZURE_ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ inputs.AZURE_ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ inputs.AZURE_ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ inputs.AZURE_ARM_TENANT_ID }}
AZURE_STORAGE_ACCOUNT: ${{ inputs.AZURE_STORAGE_ACCOUNT }}
AZURE_STORAGE_SKU: ${{ inputs.AZURE_STORAGE_SKU }}
azure_resource_identifier: ${{ inputs.azure_resource_identifier }}
azure_vm_admin_username: ${{ inputs.azure_vm_admin_username }}
azure_vm_admin_password: ${{ inputs.azure_vm_admin_password }}
AZURE_DEFAULT_REGION: ${{ inputs.AZURE_DEFAULT_REGION }}
TF_STATE_BUCKET: ${{ inputs.tf_state_bucket }}
TF_STATE_BUCKET_DESTROY: ${{ inputs.tf_state_bucket_destroy }}
REPO_ENV: ${{ inputs.repo_env }}
GHS_ENV: ${{ inputs.dot_env }}
GHV_ENV: ${{ inputs.ghv_env }}
AWS_SECRET_ENV: ${{ inputs.aws_secret_env }}
APP_PORT: ${{ inputs.app_port }}
LB_PORT: ${{ inputs.lb_port }}
LB_HEALTHCHECK: ${{ inputs.lb_healthcheck }}
AZURE_VM_SIZE: ${{ inputs.azure_vm_size }}
STACK_DESTROY: ${{ inputs.stack_destroy }}
DOMAIN_NAME: ${{ inputs.domain_name }}
SUB_DOMAIN: ${{ inputs.sub_domain }}
ROOT_DOMAIN: ${{ inputs.root_domain }}
NO_CERT: ${{ inputs.no_cert }}
BITOPS_FAST_FAIL: 'true'
DOCKER_FULL_CLEANUP: ${{ inputs.docker_full_cleanup }}
APP_DIRECTORY: ${{ inputs.app_directory }}
APP_DIRECTORY_CLEANUP: ${{ inputs.app_directory_cleanup }}
APPLICATION_MOUNT_TARGET: ${{ inputs.application_mount_target }}
DATA_MOUNT_TARGET: ${{ inputs.data_mount_target }}
ADDITIONAL_TAGS: ${{ inputs.additional_tags }}
DEBUG_MODE: ${{ inputs.DEBUG_MODE }}
run: |
echo "running operations/_scripts/deploy/deploy.sh"
$GITHUB_ACTION_PATH/operations/_scripts/deploy/deploy.sh
echo "running operations/_scripts/deploy/export_vars.sh"
$GITHUB_ACTION_PATH/operations/_scripts/deploy/export_vars.sh
# output results to GitHub
- if: ${{ success() && steps.deploy.outputs.vm_url != '' }}
name: Print result created
shell: bash
run: |
echo "## VM Created! :rocket:" >> $GITHUB_STEP_SUMMARY
echo " ${{ steps.deploy.outputs.vm_url }}" >> $GITHUB_STEP_SUMMARY
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.stack_destroy == 'true' && inputs.tf_state_bucket_destroy == 'false' }}
name: Print result destroyed
shell: bash
run: |
echo "## VM Destroyed! :boom:" >> $GITHUB_STEP_SUMMARY
echo "Infrastructure should be gone now!" >> $GITHUB_STEP_SUMMARY
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.stack_destroy == 'true' && inputs.tf_state_bucket_destroy == 'true' }}
name: Print result destroyed
shell: bash
run: |
echo "## VM Destroyed! :boom:" >> $GITHUB_STEP_SUMMARY
echo "Buckets and infrastructure should be gone now!" >> $GITHUB_STEP_SUMMARY
- if: ${{ success() && steps.deploy.outputs.vm_url == '' && inputs.stack_destroy == 'false' }}
name: Print result destroyed
shell: bash
run: |
echo "## Deploy finished! But no URL found. :thinking: " >> $GITHUB_STEP_SUMMARY
echo "If expecting an URL, please check the logs for possible errors." >> $GITHUB_STEP_SUMMARY
echo "If you consider this is a bug in the Github Action, please submit an issue to our repo." >> $GITHUB_STEP_SUMMARY
- if: ${{ failure() }}
name: Print error result
shell: bash
run: |
echo "## Workflow failed to run :fire:" >> $GITHUB_STEP_SUMMARY
echo "Please check the logs for possible errors." >> $GITHUB_STEP_SUMMARY
echo "If you consider this is a bug in the Github Action, please submit an issue to our repo." >> $GITHUB_STEP_SUMMARY