-
Notifications
You must be signed in to change notification settings - Fork 13
67 lines (57 loc) · 1.85 KB
/
cd-api-infra.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
name: Deploy API Infra
run-name: Deploy ${{ github.ref_name }} to API ${{ (github.event_name == 'release' && 'prod') || 'nonprod' }}
on:
push:
branches:
- main
paths:
- "infra/api/**"
release:
types: [published]
jobs:
build-repository:
name: Build Repository
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.7.1
terraform_wrapper: false
- name: Configure AWS credentials
uses: ./.github/actions/configure-aws-credentials
with:
app_name: api
environment: shared
- name: Build Repository
run: |
./bin/terraform-init-and-apply.sh infra/api/build-repository shared
deploy-infra:
name: Deploy Infrastructure
runs-on: ubuntu-latest
strategy:
matrix:
directory: ["database", "service"]
envs: ${{ github.event_name == 'release' && fromJSON('["prod"]') || fromJSON('["dev", "staging"]') }} # deploy prod on releases, otherwise deploy staging and dev
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.7.1
terraform_wrapper: false
- name: Configure AWS credentials
uses: ./.github/actions/configure-aws-credentials
with:
app_name: api
environment: shared
- name: Terraform Init and Apply
run: |
./bin/terraform-init.sh infra/api/${{ matrix.directory }} ${{ matrix.envs }}
export TF_CLI_ARGS="-input=false -auto-approve -var environment_name=${{ matrix.envs }}"
./bin/terraform-apply.sh infra/api/${{ matrix.directory }} ${{ matrix.envs }}