Skip to content

Commit 05d0922

Browse files
Merge pull request #2 from thiagoesteves/thi/add-gcp-terraform-files
2 parents bed940e + a583268 commit 05d0922

File tree

22 files changed

+567
-7
lines changed

22 files changed

+567
-7
lines changed

.github/workflows/full-deployment.yaml

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy a full deployment package/version to AWS
1+
name: Deploy a full deployment package/version to AWS/GCP
22

33
on:
44
workflow_call:
@@ -12,10 +12,8 @@ env:
1212

1313
jobs:
1414
build:
15-
name: Building a release and publishing it at AWS
15+
name: Building a release and version file
1616
runs-on: ubuntu-20.04
17-
permissions:
18-
contents: write
1917
steps:
2018
- uses: actions/checkout@v4
2119
- name: Setup BEAM
@@ -41,13 +39,44 @@ jobs:
4139
- name: Generate a Release
4240
run: mix release
4341

42+
- name: 'Upload release file artifact'
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: release-file
46+
path: _build/prod/calori-${{ inputs.tag }}.tar.gz
47+
retention-days: 5
48+
49+
- name: 'Upload version file artifact'
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: version-file
53+
path: current.json
54+
retention-days: 5
55+
56+
upload_aws:
57+
name: Upload files to AWS environment
58+
needs: build
59+
runs-on: ubuntu-20.04
60+
permissions:
61+
contents: write
62+
steps:
63+
- name: Download version file artefact
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: version-file
67+
68+
- name: Download release file artefact
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: release-file
72+
4473
- name: Copy a release file to the s3 distribution folder
4574
uses: prewk/s3-cp-action@v2
4675
with:
4776
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
4877
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4978
aws_region: "sa-east-1"
50-
source: "_build/prod/*.tar.gz"
79+
source: "calori-${{ inputs.tag }}.tar.gz"
5180
dest: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/dist/calori/calori-${{ inputs.tag }}.tar.gz"
5281

5382
- name: Copy a version file to the s3 version folder
@@ -58,3 +87,41 @@ jobs:
5887
aws_region: "sa-east-1"
5988
source: "current.json"
6089
dest: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}/current.json"
90+
91+
upload_gcp:
92+
name: Upload files to GCP environment
93+
needs: build
94+
runs-on: ubuntu-20.04
95+
permissions:
96+
contents: write
97+
id-token: write
98+
steps:
99+
- name: Download version file artefact
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: version-file
103+
104+
- name: Download release file artefact
105+
uses: actions/download-artifact@v4
106+
with:
107+
name: release-file
108+
109+
- id: 'auth'
110+
uses: 'google-github-actions/auth@v2'
111+
with:
112+
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
113+
service_account: ${{ secrets.SERVICE_ACCOUNT }}
114+
115+
- id: 'upload-release-file'
116+
uses: 'google-github-actions/upload-cloud-storage@v2'
117+
with:
118+
path: 'calori-${{ inputs.tag }}.tar.gz'
119+
destination: "calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/dist/calori"
120+
process_gcloudignore: false
121+
122+
- id: 'upload-version-file'
123+
uses: 'google-github-actions/upload-cloud-storage@v2'
124+
with:
125+
path: 'current.json'
126+
destination: "calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}"
127+
process_gcloudignore: false

.github/workflows/hot-upgrade.yaml

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212

1313
jobs:
1414
build:
15-
name: Building a release and publishing it at AWS
15+
name: Building a release and version file
1616
runs-on: ubuntu-20.04
1717
permissions:
1818
contents: write
@@ -66,6 +66,37 @@ jobs:
6666
- name: Generate a Release
6767
run: mix release
6868

69+
- name: 'Upload release file artifact'
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: release-file
73+
path: _build/prod/calori-${{ inputs.tag }}.tar.gz
74+
retention-days: 5
75+
76+
- name: 'Upload version file artifact'
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: version-file
80+
path: current.json
81+
retention-days: 5
82+
83+
upload_aws:
84+
name: Upload files to AWS environment
85+
needs: build
86+
runs-on: ubuntu-20.04
87+
permissions:
88+
contents: write
89+
steps:
90+
- name: Download version file artefact
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: version-file
94+
95+
- name: Download release file artefact
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: release-file
99+
69100
- name: Copy a release file to the s3 distribution folder
70101
uses: prewk/s3-cp-action@v2
71102
with:
@@ -83,3 +114,41 @@ jobs:
83114
aws_region: "sa-east-1"
84115
source: "current.json"
85116
dest: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}/current.json"
117+
118+
upload_gcp:
119+
name: Upload files to GCP environment
120+
needs: build
121+
runs-on: ubuntu-20.04
122+
permissions:
123+
contents: write
124+
id-token: write
125+
steps:
126+
- name: Download version file artefact
127+
uses: actions/download-artifact@v4
128+
with:
129+
name: version-file
130+
131+
- name: Download release file artefact
132+
uses: actions/download-artifact@v4
133+
with:
134+
name: release-file
135+
136+
- id: 'auth'
137+
uses: 'google-github-actions/auth@v2'
138+
with:
139+
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
140+
service_account: ${{ secrets.SERVICE_ACCOUNT }}
141+
142+
- id: 'upload-release-file'
143+
uses: 'google-github-actions/upload-cloud-storage@v2'
144+
with:
145+
path: 'calori-${{ inputs.tag }}.tar.gz'
146+
destination: "calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/dist/calori"
147+
process_gcloudignore: false
148+
149+
- id: 'upload-version-file'
150+
uses: 'google-github-actions/upload-cloud-storage@v2'
151+
with:
152+
path: 'current.json'
153+
destination: "calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}"
154+
process_gcloudignore: false
File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main.tf
2+
.terraform.lock.hcl

devops/terraform/modules/standard-account/cloud-config.tpl renamed to devops/aws/terraform/modules/standard-account/cloud-config.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ write_files:
3737
"replicas": ${replicas},
3838
"account_name": "${account_name}",
3939
"deployex_hostname": "${deployex_hostname}",
40+
"release_adapter": "s3",
41+
"release_bucket": "calori-${account_name}-distribution",
42+
"secrets_adapter": "aws",
43+
"secrets_path": "deployex-calori-${account_name}-secrets",
4044
"aws_region": "${aws_region}",
4145
"version": "${deployex_version}",
4246
"os_target": "ubuntu-20.04",

devops/gcp/terraform/.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
### macOS ###
2+
# General
3+
.DS_Store
4+
.AppleDouble
5+
.LSOverride
6+
7+
# Thumbnails
8+
._*
9+
10+
### Terraform ###
11+
# Local .terraform directories
12+
**/.terraform/*
13+
14+
# .tfstate files
15+
*.tfstate
16+
*.tfstate.*
17+
18+
# Crash log files
19+
crash.log
20+
crash.*.log
21+
22+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
23+
# password, private keys, and other secrets. These should not be part of version
24+
# control as they are data points which are potentially sensitive and subject
25+
# to change depending on the environment.
26+
*.tfvars
27+
*.tfvars.json
28+
29+
# Ignore override files as they are usually used to override resources locally and so
30+
# are not checked in
31+
override.tf
32+
override.tf.json
33+
*_override.tf
34+
*_override.tf.json
35+
36+
# Include override files you do wish to add to version control using negated pattern
37+
# !example_override.tf
38+
39+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
40+
# example: *tfplan*
41+
42+
# Ignore CLI configuration files
43+
.terraformrc
44+
terraform.rc
45+
46+
### Terragrunt ###
47+
# terragrunt cache directories
48+
**/.terragrunt-cache/*
49+
50+
# Terragrunt debug output file (when using `--terragrunt-debug` option)
51+
# See: https://terragrunt.gruntwork.io/docs/reference/cli-options/#terragrunt-debug
52+
terragrunt-debug.tfvars.json
53+
54+
### VisualStudioCode ###
55+
.vscode/*
56+
!.vscode/settings.json
57+
!.vscode/tasks.json
58+
!.vscode/launch.json
59+
!.vscode/extensions.json
60+
!.vscode/*.code-snippets
61+
62+
# credentials
63+
deployex-gcp-terraform.json
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main.tf
2+
.terraform.lock.hcl
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Rename me to main.tf and populated with the corrected values
2+
3+
provider "google" {
4+
project = <project_id> # From deployex-gcp-terraform.json (project_id)
5+
region = <region> # Example "us-central1"
6+
access_token = <token> # From GCP CLI terminal "gcloud beta auth application-default print-access-token"
7+
}
8+
9+
module "standard_account" {
10+
source = "../../modules/standard-account"
11+
account_name = "prod"
12+
server_dns = "deployex.pro"
13+
replicas = "3"
14+
machine_type = "e2-micro"
15+
deployex_dns = "deployex.deployex.pro"
16+
deployex_version = "0.3.0-rc14"
17+
}

0 commit comments

Comments
 (0)