chore: update workflow for opentofu
This commit is contained in:
51
.github/workflows/infra-build.yml
vendored
51
.github/workflows/infra-build.yml
vendored
@@ -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
|
||||
|
Reference in New Issue
Block a user