This commit is contained in:
29
.github/workflows/terraform.yaml
vendored
29
.github/workflows/terraform.yaml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Terraform
|
name: Terraform CI/CD
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -12,29 +12,36 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
working-directory: terraform
|
working-directory: terraform
|
||||||
|
|
||||||
|
container:
|
||||||
|
image: hashicorp/terraform:1.6.6
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Install dependencies
|
||||||
|
run: apk add --no-cache nodejs npm git
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Terraform
|
|
||||||
uses: hashicorp/setup-terraform@v3
|
|
||||||
|
|
||||||
- name: Terraform Init
|
- name: Terraform Init
|
||||||
run: terraform init -input=false
|
run: terraform -chdir=terraform init -input=false
|
||||||
|
|
||||||
- name: Terraform Validate
|
- name: Terraform Validate
|
||||||
run: terraform validate
|
run: terraform -chdir=terraform validate
|
||||||
|
|
||||||
- name: Terraform Plan
|
- name: Terraform Plan
|
||||||
run: terraform plan -input=false -out=tfplan
|
run: terraform -chdir=terraform plan -input=false -out=tfplan
|
||||||
|
|
||||||
- name: Upload plan
|
- name: Show plan
|
||||||
|
run: terraform -chdir=terraform show -no-color tfplan > terraform/plan.txt
|
||||||
|
|
||||||
|
- name: Upload plan artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: terraform-plan
|
name: terraform-plan
|
||||||
path: terraform/tfplan
|
path: |
|
||||||
|
terraform/tfplan
|
||||||
|
terraform/plan.txt
|
||||||
|
|
||||||
# Optional: apply only on main
|
|
||||||
- name: Terraform Apply
|
- name: Terraform Apply
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
run: terraform apply -input=false -auto-approve tfplan
|
run: terraform -chdir=terraform apply -input=false -auto-approve tfplan
|
||||||
|
|||||||
Reference in New Issue
Block a user