Skip to content

Commit

Permalink
beta
Browse files Browse the repository at this point in the history
  • Loading branch information
LamSut committed Oct 16, 2024
1 parent 648cb1b commit 77b8032
Showing 1 changed file with 44 additions and 25 deletions.
69 changes: 44 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@
name: Terraform AWS
name: Terraform CI/CD

on:
push:
branches:
- main
branches: [ main ]

jobs:
tf_fmt:
name: Deploy Site
runs-on: ubuntu-latest
terraform:
runs-on: ubuntu-latest

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_DEFAULT_REGION: "us-east-1"

steps:
- uses: actions/checkout@v3

- name: Use Terraform Cache
uses: actions/cache@v3
with:
path: ~/.terraform
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock') }}
restore-keys: |
${{ runner.os }}-terraform-
- name: Install Terraform
uses: hashicorp/setup-terraform@v2

- name: Terraform Version
run: terraform --version

- name: Initialize Terraform
run: terraform init

- name: Terraform Validate
run: terraform validate

- id: plan
name: Terraform Plan
run: terraform plan -out=planfile

- name: Upload Plan (Optional)
uses: actions/upload-artifact@v3
with:
name: planfile
path: planfile
if: success()

- name: Checkout Repo
uses: actions/checkout@v1

- name: Terraform Init
uses: hashicorp/terraform-github-actions/init@v0.4.0
env:
TF_ACTION_WORKING_DIR: 'terraform'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Terraform Validate
uses: hashicorp/terraform-github-actions/validate@v0.3.7

- name: Terraform Apply
uses: hashicorp/terraform-github-actions/apply@v0.4.0
env:
TF_ACTION_WORKING_DIR: 'terraform'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Apply Terraform
run: terraform apply -input=false planfile

0 comments on commit 77b8032

Please sign in to comment.