Skip to content

Instantly share code, notes, and snippets.

@lucamilan
Created September 16, 2022 07:55
Show Gist options
  • Save lucamilan/684aeb51b3600e1f7ec6f7190384de09 to your computer and use it in GitHub Desktop.
Save lucamilan/684aeb51b3600e1f7ec6f7190384de09 to your computer and use it in GitHub Desktop.
Simple Terraform deploy pipeline
name: Terraform Sample 1
env:
tf_directory: sample-1
on:
push:
paths:
- 'sample-1/**'
workflow_dispatch:
jobs:
terraform:
name: "Terraform Sample 1"
runs-on: ubuntu-latest
environment: tf-development
defaults:
run:
working-directory: ./${{env.tf_directory}}
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.2.8
- name: Terraform Format Check
continue-on-error: true
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 -out tf.state -no-color -input=false
continue-on-error: true
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
run: terraform apply -auto-approve -input=false
- name: Terraform Create Issue
uses: alialaa/issue-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Terraform results ${{ github.actor }}
body: "#### Initialization ⚙️${{ steps.init.outcome }}\n #### Plan 📖${{ steps.plan.outcome }}\n #### Validation 🤖 ${{ steps.validate.outcome }}\n### Output ☄️\n${{ steps.plan.outputs.stdout }}"
assignees: |
lucamilan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment