Skip to content

feat(ci): add terraform apply on main branch #9

feat(ci): add terraform apply on main branch

feat(ci): add terraform apply on main branch #9

Workflow file for this run

name: 'Terraform'
on:
push:
branches: [ "main" ]
pull_request:
jobs:
terraform:
name: 'Terraform'
runs-on: self-hosted
environment: pve0
env:
PROXMOX_VE_ENDPOINT: ${{vars.PROXMOX_VE_ENDPOINT}}
PROXMOX_VE_INSECURE: ${{vars.PROXMOX_VE_INSECURE}}
PROXMOX_VE_SSH_USERNAME: ${{secrets.PROXMOX_VE_SSH_USERNAME}}
PROXMOX_VE_SSH_PASSWORD: ${{secrets.PROXMOX_VE_SSH_PASSWORD}}
PROXMOX_VE_API_TOKEN: ${{secrets.PROXMOX_VE_API_TOKEN}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Init
run: terraform init
- name: Terraform Format
run: terraform fmt -check -diff -recursive
- name: Create terraform.tfvars
run: |
envsubst '$TF_VAR_GITHUB_PAT' < github-actions.tfvars.template > terraform.tfvars
- name: Terraform Validate
run: terraform validate
- name: Terraform Plan
run: terraform plan -out tfplan
- name: Terraform Apply
if: ${{ github.ref == 'refs/heads/main' }}
run: terraform apply tfplan