-
Notifications
You must be signed in to change notification settings - Fork 15
87 lines (82 loc) · 3.02 KB
/
run-deployer.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
name: Setup Deployment Machine
on:
workflow_dispatch:
inputs:
destroy_instance:
description: destroy-deployment-machine
required: true
type: choice
default: "false"
options:
- true
- false
root_ssh_pub_key:
description: root-ssh-public-key
required: true
type: string
deployr_ssh_pub_key:
description: admin-ssh-public-key
required: true
type: string
openssl_cipher_text:
description: openssl-cipher-text
required: true
type: string
deploy_script_branch:
description: deployment-script-branch
type: string
default: "lisbon-deployment"
jobs:
create-destroy-deployment-machine:
runs-on: ubuntu-latest
# environment:
# name: lisbon-deployment
permissions:
packages: write
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- name: configureawscredentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_STS_ROLE }}
role-session-name: cicdtestnet
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Terraform Apply
id: apply
env:
TF_VAR_root_ssh_pub_key: "${{ github.event.inputs.root_ssh_pub_key }}"
TF_VAR_vpc_id: "${{ secrets.VPC_ID }}"
TF_VAR_subnet_id: "${{ secrets.SUBNET_ID }}"
TF_VAR_vpc_security_group_ids: "${{ secrets.SECURITY_GROUP_ID }}"
kms_id: "${{ secrets.LISBON_KMS_ID }}"
ci_user: "${{ secrets.CI_USER }}"
repo_token: "${{ secrets.DEVNET_REPO_ACCESS }}"
deployr_ssh_pub_key: "${{ github.event.inputs.deployr_ssh_pub_key }}"
deploy_script_branch: "${{ github.event.inputs.deploy_script_branch }}"
soroban_secret_key_testnet: "${{ secrets.SOROBAN_SECRET_KEY_TESTNET }}"
run: |
cipher_text=$(jq -r '.inputs.openssl_cipher_text' $GITHUB_EVENT_PATH)
echo ::add-mask::$cipher_text
cd .github/deployer
echo "$TF_VAR_root_ssh_pub_key" > id_rsa.pub
sed -i "s|SSH_PUBKEY_HERE|$deployr_ssh_pub_key|g" init_script.sh
sed -i "s|CIPHER_TEXT_HERE|$cipher_text|g" init_script.sh
sed -i "s|DEPLOY_SCRIPT_BRANCH_HERE|$deploy_script_branch|g" init_script.sh
sed -i "s|KMS_ID_HERE|$kms_id|g" init_script.sh
sed -i "s|GITHUB_TOKEN_HERE|$repo_token|g" init_script.sh
sed -i "s|CI_USER_HERE|$ci_user|g" init_script.sh
sed -i "s|SOROBAN_SECRET_KEY_HERE|$soroban_secret_key_testnet|g" init_script.sh
terraform init
terraform validate
terraform plan
if [[ "${{ github.event.inputs.destroy_instance }}" == "true" ]]; then
terraform destroy -auto-approve
else
terraform apply -auto-approve
fi