Skip to content

Commit

Permalink
add terraform apply
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelnikolov committed Jul 25, 2024
1 parent 0aee616 commit 673d6b9
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Network Terraform Apply"

on:
push:
branches:
- main
paths:
- 'terraform/**'
workflow_dispatch:

env:
TF_WORKSPACE: "default"
CONFIG_DIRECTORY: "./terraform"

jobs:
terraform:
name: "Network Terraform Plan & Apply"
runs-on: ubuntu-latest

defaults:
run:
working-directory: ${{ env.CONFIG_DIRECTORY }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- name: Assume AWS Credentials
id: assume
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: ${{ github.actor }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}

- uses: hashicorp/setup-terraform@v3

- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true

- 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 -out=tf.plan

- name: Terraform Apply
run: terraform apply -auto-approve tf.plan
4 changes: 2 additions & 2 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: "Terraform Plan"

on:
pull_request:
# paths:
# - './terraform/**'
paths:
- 'terraform/**'

env:
TF_WORKSPACE: "default"
Expand Down

0 comments on commit 673d6b9

Please sign in to comment.