From 665be99089dea88fa9bdd0fb9677fc3cc2ddd993 Mon Sep 17 00:00:00 2001 From: Matthew McKinnon Date: Sat, 27 Sep 2025 13:23:08 +1000 Subject: [PATCH] chore: update workflow for opentofu --- .github/workflows/infra-build.yml | 51 ++++++++++++++++++------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/.github/workflows/infra-build.yml b/.github/workflows/infra-build.yml index 824c795..8d322fb 100644 --- a/.github/workflows/infra-build.yml +++ b/.github/workflows/infra-build.yml @@ -1,4 +1,4 @@ -name: Build Infra +name: Build Infra (Opentofu) on: push: @@ -6,35 +6,28 @@ on: - master jobs: - terraform: - name: Terraform Build + opentofu: + name: Opentofu Build runs-on: self-hosted env: - PG_CONN_STR: ${{ secrets.PG_CONN_STR }} # <-- Add PostgreSQL backend connection string + PG_CONN_STR: ${{ secrets.PG_CONN_STR }} + + defaults: + run: + working-directory: ./opentofu-homelab + steps: - name: Checkout code uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Setup Terraform - uses: hashicorp/setup-terraform@v2 - - - name: Terraform Init - run: terraform init - - - name: Terraform Format Check - run: terraform fmt -check -recursive - - - name: Terraform Validate - run: terraform validate - - - name: Terraform Plan - id: plan + - name: Setup Opentofu CLI run: | - terraform plan -out=tfplan -detailed-exitcode - continue-on-error: false + curl -L https://github.com/opentofu/opentofu/releases/latest/download/opentofu-linux-amd64 -o /usr/local/bin/tofu + chmod +x /usr/local/bin/tofu + tofu version - name: Generate Dynamic Vars (Secrets) run: | @@ -48,6 +41,20 @@ jobs: passphrase = "${{ secrets.SSH_PASSPHRASE }}" EOF - - name: Terraform Apply + - name: Opentofu Init + run: tofu init + + - name: Opentofu Format Check + run: tofu fmt -check -recursive + + - name: Opentofu Validate + run: tofu validate + + - name: Opentofu Plan + id: plan + run: | + tofu plan -out=tfplan -detailed-exitcode + + - name: Opentofu Apply if: success() - run: terraform apply -auto-approve tfplan + run: tofu apply -auto-approve tfplan