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:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,35 +6,28 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
terraform:
|
opentofu:
|
||||||
name: Terraform Build
|
name: Opentofu Build
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
|
|
||||||
env:
|
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:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Terraform
|
- name: Setup Opentofu CLI
|
||||||
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
|
|
||||||
run: |
|
run: |
|
||||||
terraform plan -out=tfplan -detailed-exitcode
|
curl -L https://github.com/opentofu/opentofu/releases/latest/download/opentofu-linux-amd64 -o /usr/local/bin/tofu
|
||||||
continue-on-error: false
|
chmod +x /usr/local/bin/tofu
|
||||||
|
tofu version
|
||||||
|
|
||||||
- name: Generate Dynamic Vars (Secrets)
|
- name: Generate Dynamic Vars (Secrets)
|
||||||
run: |
|
run: |
|
||||||
@@ -48,6 +41,20 @@ jobs:
|
|||||||
passphrase = "${{ secrets.SSH_PASSPHRASE }}"
|
passphrase = "${{ secrets.SSH_PASSPHRASE }}"
|
||||||
EOF
|
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()
|
if: success()
|
||||||
run: terraform apply -auto-approve tfplan
|
run: tofu apply -auto-approve tfplan
|
||||||
|
Reference in New Issue
Block a user