-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (56 loc) · 1.62 KB
/
deploy-app-ec2.yml
File metadata and controls
69 lines (56 loc) · 1.62 KB
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
name: Terraform - EC2
on:
workflow_run:
workflows: ["Docker Image Pipeline"]
branches:
- main
- master
- develop
- v1.1.0-preview.6
types: [opened, synchronize, reopened, completed]
env:
REGISTRY: ghcr.io/answerconsulting/answerking-java
IMAGE_NAME: answer-king-rest-api_app
jobs:
terraform_apply:
runs-on: ubuntu-latest
name: Terraform
permissions:
contents: read
packages: write
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_db_password: ${{secrets.db_password}}
defaults:
run:
shell: bash
working-directory: ./terraform
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.7
terraform_wrapper: false
- name: Terraform format
id: fmt
run: terraform fmt -check
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Plan
id: plan
run: terraform plan -no-color -input=false
continue-on-error: true
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve -input=false