-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (82 loc) · 3.92 KB
/
terraform-apply.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
name: Apply Terraform on Google Cloud
on:
workflow_run:
workflows: ["Build and Push Docker Image"]
types:
- completed
jobs:
terraform:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up gcloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Install Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.6.5
- name: Terraform Init
working-directory: infra/prod
run: terraform init
env:
GOOGLE_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GOOGLE_CREDENTIALS: ${{ secrets.GCP_SA_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Terraform Refresh
working-directory: infra/prod
run: |
export TF_VAR_env="prod"
export TF_VAR_gcp_project_id="${{ secrets.GCP_PROJECT_ID }}"
export TF_VAR_aws_cognito_user_pool_id="${{ secrets.COGNITO_USER_POOL_ID }}"
export TF_VAR_aws_cognito_client_id="${{ secrets.COGNITO_CLIENT_ID }}"
export TF_VAR_aws_cognito_domain="${{ secrets.COGNITO_DOMAIN }}"
export TF_VAR_aws_cognito_client_secret="${{ secrets.COGNITO_CLIENT_SECRET }}"
export TF_VAR_aws_cognito_redirect_url="${{ secrets.COGNITO_REDIRECT_URI }}"
export TF_VAR_chainlit_auth_secret="${{ secrets.CHAINLIT_AUTH_SECRET }}"
export TF_VAR_chainlit_api_key="${{ secrets.CHAINLIT_API_KEY }}"
export TF_VAR_openai_api_key="${{ secrets.OPENAI_API_KEY }}"
export TF_VAR_redis_port="${{ secrets.REDIS_PORT }}"
export TF_VAR_redis_db="${{ secrets.REDIS_DB }}"
export TF_VAR_redis_ttl="${{ secrets.REDIS_TTL }}"
terraform refresh -input=false
env:
GOOGLE_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GOOGLE_CREDENTIALS: ${{ secrets.GCP_SA_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Terraform DBG
working-directory: infra/prod
run: terraform state list
env:
GOOGLE_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GOOGLE_CREDENTIALS: ${{ secrets.GCP_SA_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Terraform Apply
working-directory: infra/prod
run: |
export TF_VAR_env="prod"
export TF_VAR_gcp_project_id="${{ secrets.GCP_PROJECT_ID }}"
export TF_VAR_aws_cognito_user_pool_id="${{ secrets.COGNITO_USER_POOL_ID }}"
export TF_VAR_aws_cognito_client_id="${{ secrets.COGNITO_CLIENT_ID }}"
export TF_VAR_aws_cognito_domain="${{ secrets.COGNITO_DOMAIN }}"
export TF_VAR_aws_cognito_client_secret="${{ secrets.COGNITO_CLIENT_SECRET }}"
export TF_VAR_aws_cognito_redirect_url="${{ secrets.COGNITO_REDIRECT_URI }}"
export TF_VAR_chainlit_auth_secret="${{ secrets.CHAINLIT_AUTH_SECRET }}"
export TF_VAR_chainlit_api_key="${{ secrets.CHAINLIT_API_KEY }}"
export TF_VAR_openai_api_key="${{ secrets.OPENAI_API_KEY }}"
export TF_VAR_redis_port="${{ secrets.REDIS_PORT }}"
export TF_VAR_redis_db="${{ secrets.REDIS_DB }}"
export TF_VAR_redis_ttl="${{ secrets.REDIS_TTL }}"
terraform plan -input=false -out=tfplan
# terraform apply -input=false tfplan
env:
GOOGLE_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GOOGLE_CREDENTIALS: ${{ secrets.GCP_SA_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}