-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (36 loc) · 1.18 KB
/
cd.yaml
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
name: Deploy or Destroy
on:
workflow_dispatch:
inputs:
destroy_flag:
description: 'Flag to trigger destroy'
required: true
default: "false"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Passo 1: Checkout do código
- name: Checkout code
uses: actions/checkout@v2
# Passo 2: Configurar as credenciais da AWS
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
# Passo 3: Instalar o Terraform
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
# Passo 4: Inicializar o Terraform com o backend remoto
- name: Initialize Terraform
run: terraform init
# Passo 5: Aplicar ou Destruir a Infraestrutura
- name: Apply or Destroy Terraform
run: |
if [ "${{ github.event.inputs.destroy_flag }}" == "true" ]; then
terraform destroy -auto-approve
else
terraform apply -auto-approve
fi