-
Notifications
You must be signed in to change notification settings - Fork 9
133 lines (106 loc) · 3.68 KB
/
rc-deploy.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
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
name: RC - Deploy
on:
workflow_dispatch:
env:
AWS_REGION: ap-northeast-2
ECS_CLUSTER: Codedang-Api
permissions: # permissions to the job (for the OpenID Connection)
id-token: write
contents: read
jobs:
rc-deploy-network:
name: RC - Deploy Network
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_FOR_DEPLOY_RC }}
aws-region: ${{ env.AWS_REGION }}
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.2
- name: Create Terraform variable file
working-directory: ./apps/infra/rc/network
run: |
echo 'env = "rc"' >> terraform.tfvars
- name: Terraform Init
working-directory: ./apps/infra/rc/network
run: terraform init -backend-config="bucket=codedang-tf-state-rc"
- name: Terraform Plan
working-directory: ./apps/infra/rc/network
run: terraform plan -input=false -out=plan.out
- name: Terraform Apply
working-directory: ./apps/infra/rc/network
run: terraform apply -input=false plan.out
rc-deploy-storage:
name: RC - Deploy Storage
runs-on: ubuntu-latest
needs: [rc-deploy-network]
environment: production
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_FOR_DEPLOY_RC }}
aws-region: ${{ env.AWS_REGION }}
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.2
- name: Create Terraform variable file
working-directory: ./apps/infra/rc/storage
run: |
echo 'env = "rc"' >> terraform.tfvars
- name: Terraform Init
working-directory: ./apps/infra/rc/storage
run: terraform init -backend-config="bucket=codedang-tf-state-rc"
- name: Terraform Plan
working-directory: ./apps/infra/rc/storage
run: terraform plan -input=false -out=plan.out
- name: Terraform Apply
working-directory: ./apps/infra/rc/storage
run: terraform apply -input=false plan.out
rc-deploy-codedang:
name: RC - Deploy Codedang
runs-on: ubuntu-latest
needs: [rc-deploy-network, rc-deploy-storage]
environment: production
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_FOR_DEPLOY_RC }}
aws-region: ${{ env.AWS_REGION }}
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.2
- name: Create Terraform variable file
working-directory: ./apps/infra/rc/codedang
run: |
echo "$TFVARS_RC" >> terraform.tfvars
echo "$OAUTH_GITHUB" >> terraform.tfvars
echo "$OAUTH_KAKAO" >> terraform.tfvars
echo 'env = "rc"' >> terraform.tfvars
env:
TFVARS_RC: ${{ secrets.TFVARS_RC }}
OAUTH_GITHUB: ${{ secrets.OAUTH_GITHUB }}
OAUTH_KAKAO: ${{ secrets.OAUTH_KAKAO }}
- name: Terraform Init
working-directory: ./apps/infra/rc/codedang
run: terraform init -backend-config="bucket=codedang-tf-state-rc"
- name: Terraform Plan
working-directory: ./apps/infra/rc/codedang
run: terraform plan -input=false -out=plan.out
- name: Terraform Apply
working-directory: ./apps/infra/rc/codedang
run: terraform apply -input=false plan.out