Files
homelab-infra/.gitea/workflows/terraform.yml
panxiao81 8f6b08bd20
yaml / yaml (pull_request) Successful in 20s
terraform / validate (pull_request) Successful in 22s
ansible / lint (pull_request) Successful in 4m5s
ci: 按路径拆分静态检查
2026-09-10 08:33:26 +00:00

36 lines
912 B
YAML

---
name: terraform
on:
push:
branches: [main]
paths:
- '**/*.tf'
- '**/.terraform.lock.hcl'
- '.gitea/workflows/terraform.yml'
pull_request:
paths:
- '**/*.tf'
- '**/.terraform.lock.hcl'
- '.gitea/workflows/terraform.yml'
jobs:
validate:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- name: fmt and validate
# -backend=false so validate never touches real state or needs credentials.
run: |
rc=0
for d in $(git ls-files '*.tf' | xargs -n1 dirname | sort -u); do
echo "::group::$d"
terraform -chdir="$d" fmt -check -diff || rc=1
terraform -chdir="$d" init -backend=false -input=false || rc=1
terraform -chdir="$d" validate || rc=1
echo "::endgroup::"
done
exit $rc