-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (43 loc) · 1.26 KB
/
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
name: Deploy
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
terraform:
name: Terraform Plan and Apply
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Format Check
run: terraform fmt -check
continue-on-error: true
- name: Initialize Terraform
run: terraform init
- name: Terraform Validate
run: terraform validate
- name: Terraform Plan
id: plan
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: terraform plan -no-color -out=tfplan
- name: Terraform Apply
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: terraform apply -auto-approve tfplan