Files
netbird-iac/.gitea/workflows/terraform.yml
Prox b68cc22b38
All checks were successful
Terraform / terraform (push) Successful in 13s
fix: move workflow to repo root, add working-directory for terraform
2026-02-15 18:41:52 +02:00

57 lines
1.4 KiB
YAML

name: Terraform
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
TF_VAR_netbird_token: ${{ secrets.NETBIRD_TOKEN }}
defaults:
run:
working-directory: terraform
jobs:
terraform:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.0
- name: Terraform Init
run: terraform init
- name: Terraform Format Check
run: terraform fmt -check
continue-on-error: true
- name: Terraform Validate
run: terraform validate
- name: Terraform Plan
if: github.event_name == 'pull_request'
run: terraform plan -no-color
- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve
- name: Commit state changes
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
working-directory: .
run: |
git config user.name "Terraform CI"
git config user.email "ci@localhost"
git add terraform/terraform.tfstate terraform/terraform.tfstate.backup 2>/dev/null || true
if ! git diff --staged --quiet; then
git commit -m "chore: update terraform state [skip ci]"
git push
fi