feat(ci): only run tofu fmt when necessary

Signed-off-by: Vegard Hagen <[email protected]>
This commit is contained in:
Vegard Stenhjem Hagen
2025-07-16 23:54:47 +02:00
committed by Vegard Hagen
parent 53ef70cc44
commit eaf7c15a8f
2 changed files with 15 additions and 19 deletions
+5 -4
View File
@@ -2,13 +2,14 @@ FROM docker.io/ubuntu:24.04
ARG TARGETARCH
ARG USER_ID=1000
ARG USER_GID=1000
ARG USER_ID=1001
ARG USER_GID=1001
ARG USERNAME=dev
RUN userdel ubuntu && \
rm -rf /home/ubuntu
# Remove ubuntu user
RUN userdel -r ubuntu
# Install common packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https \
+10 -15
View File
@@ -1,4 +1,4 @@
name: OpenTofu validation
name: Tofu format
on:
push:
@@ -9,31 +9,26 @@ on:
- '**.tfvars'
- '**.tftpl'
pull_request:
branches: [ main ]
pull_request_target:
branches: [ main ]
types: [ opened, synchronize ]
branches: [ '**' ]
paths:
- '**.tf'
- '**.tofu'
- '**.tfvars'
- '**.tftpl'
jobs:
tofu-format:
name: Validate
name: run tofu format
runs-on: ubuntu-latest
permissions:
contents: read
env:
TOFU_DIR: tofu
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Login to GitHub Container Registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 #v3.4.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tofu format
uses: docker://ghcr.io/vehagn/homelab-devcontainer
with:
args: tofu -chdir=${{ env.TOFU_DIR }} fmt -recursive -diff -check
args: tofu fmt -recursive -diff -check