-
Notifications
You must be signed in to change notification settings - Fork 9
103 lines (88 loc) · 3.12 KB
/
cd-prod-target.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
name: CD - Production Target
on:
workflow_dispatch:
inputs:
terraform_project:
description: 'Select Terraform Project to Update'
required: true
type: choice
options:
- 'storage'
- 'network'
permissions: # permissions to the job (for the OpenID Connection)
id-token: write
contents: read
jobs:
deploy-terraform-target-project:
name: Deploy Terraform targeted Project
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_FOR_DEPLOY }}
aws-region: ap-northeast-2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.2
- name: Create Terraform variable file
working-directory: ./apps/infra/production/${{ github.event.inputs.terraform_project }}
run: |
echo "$TFVARS_TARGET" >> terraform.tfvars
env:
TFVARS_TARGET: ${{ secrets.TFVARS_TARGET }}
- name: Terraform Init
working-directory: ./apps/infra/production/${{ github.event.inputs.terraform_project }}
run: terraform init
- name: Terraform Plan
working-directory: ./apps/infra/production/${{ github.event.inputs.terraform_project }}
run: terraform plan -input=false -out=plan.out
- name: Terraform Apply
working-directory: ./apps/infra/production/${{ github.event.inputs.terraform_project }}
run: terraform apply -input=false plan.out
deploy-terraform-codedang:
name: Deploy Terraform Codedang Project
runs-on: ubuntu-latest
needs: [deploy-terraform-target-project]
environment: production
defaults:
run:
shell: bash
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_FOR_DEPLOY }}
aws-region: ap-northeast-2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.2
- name: Create Terraform variable file
working-directory: ./apps/infra/production/codedang
run: |
echo "$TFVARS" >> terraform.tfvars
echo "$OAUTH_GITHUB" >> terraform.tfvars
echo "$OAUTH_KAKAO" >> terraform.tfvars
env:
TFVARS: ${{ secrets.TFVARS }}
OAUTH_GITHUB: ${{ secrets.OAUTH_GITHUB }}
OAUTH_KAKAO: ${{ secrets.OAUTH_KAKAO }}
- name: Terraform Init
working-directory: ./apps/infra/production/codedang
run: terraform init
- name: Terraform Plan
working-directory: ./apps/infra/production/codedang
run: terraform plan -input=false -out=plan.out
- name: Terraform Apply
working-directory: ./apps/infra/production/codedang
run: terraform apply -input=false plan.out