Skip to content

GitHub IaC

GitHub IaC #12

Workflow file for this run

name: GitHub IaC
# yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
apply:
description: Should the plan also be applied?
type: boolean
required: true
default: false
repository_dispatch:
types:
- addons-update
push:
branches:
- main
paths:
- github-iac
jobs:
plan:
name: πŸ“ Plan IaC changes
runs-on: ubuntu-latest
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: πŸ—οΈ Setup terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.6"
cli_config_credentials_token: ${{ secrets.TERRAFORM_CLOUD_TOKEN }}
- name: ‡️ Download latest addons.yml file from stable repository
uses: enflo/curl-action@v1
with:
curl: -o addons.yml https://raw.githubusercontent.com/Poeschl-HomeAssistant-Addons/repository/refs/heads/main/.addons.yml
- name: πŸ‘€ View addons config
run: cat addons.yml
- name: πŸ—οΈ Terraform init
env:
GITHUB_TOKEN: ${{ secrets.IAC_TOKEN }}
run: cd github-iac && terraform init
- name: πŸ“ Terraform plan
id: plan
env:
GITHUB_TOKEN: ${{ secrets.IAC_TOKEN }}
run: cd github-iac && terraform plan -out plan.out
- name: ‴️ Upload plan
uses: actions/upload-artifact@v4
with:
name: github-iac-artifact
path: github-iac/plan.out
apply:
name: πŸš€ Apply IaC changes
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.apply == 'true'
needs:
- plan
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: πŸ—οΈ Setup terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.6"
cli_config_credentials_token: ${{ secrets.TERRAFORM_CLOUD_TOKEN }}
- name: ‡️ Get plan artifact
uses: actions/download-artifact@v4
with:
name: github-iac-artifact
path: github-iac
- name: ‡️ Download latest addons.yml file from stable repository
uses: enflo/curl-action@v1
with:
curl: -o addons.yml https://raw.githubusercontent.com/Poeschl-HomeAssistant-Addons/repository/refs/heads/main/.addons.yml
- name: πŸ—οΈ Terraform init
env:
GITHUB_TOKEN: ${{ secrets.IAC_TOKEN }}
run: cd github-iac && terraform init
- name: πŸš€ Apply plan
env:
GITHUB_TOKEN: ${{ secrets.IAC_TOKEN }}
run: cd github-iac && terraform apply -auto-approve plan.out