48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
name: Terraform CI
|
|
run-name: ${{ gitea.actor }} triggered a Terraform CI
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
terraform:
|
|
runs-on: infra-terraform
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: stacks/prod/proxmox
|
|
|
|
env:
|
|
# TODO: migrate to Openbao
|
|
PROXMOX_VE_ENDPOINT: ${{ secrets.PROXMOX_VE_ENDPOINT }}
|
|
PROXMOX_VE_API_TOKEN: ${{ secrets.PROXMOX_VE_API_TOKEN }}
|
|
PROXMOX_VE_SSH_PRIVATE_KEY: ${{ secrets.PROXMOX_VE_SSH_PRIVATE_KEY }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Terraform
|
|
uses: hashicorp/setup-terraform@v3
|
|
with:
|
|
terraform_version: 1.13.3
|
|
|
|
# Job will fail if you didn't run `terraform fmt -recursive`
|
|
- name: Check formatting
|
|
run: terraform fmt -check -recursive
|
|
|
|
- name: Initialize Terraform modules
|
|
run: terraform init
|
|
|
|
- name: Validate Terraform
|
|
run: terraform validate
|
|
|
|
- name: Create Terraform plan
|
|
run: terraform plan -out=tfplan
|
|
|
|
# Job will apply the plan if pushed to main
|
|
- name: Conditionally apply the Terraform plan
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
run: terraform apply -auto-approve tfplan
|
|
|