Skip to content

Terraform formatting #1

Terraform formatting

Terraform formatting #1

Workflow file for this run

name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
terraform-validation:
name: Terraform Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Format Check
id: fmt
run: terraform fmt -check -recursive operations/deployment/terraform/
continue-on-error: true
- name: Create mock provider.tf
run: |
cat > operations/deployment/terraform/aws/provider.tf << 'EOF'
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
random = {
source = "hashicorp/random"
version = ">= 2.2"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.22"
}
}
}
provider "aws" {
region = "us-east-1"
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
}
EOF
- name: Create mock terraform.tfvars
run: |
cat > operations/deployment/terraform/aws/terraform.tfvars << 'EOF'
aws_resource_identifier = "test-repo-branch"
aws_resource_identifier_supershort = "test-repo-branch"
app_repo_name = "test-repo"
app_org_name = "test-org"
app_branch_name = "test-branch"
ops_repo_environment = "deployment"
app_install_root = "/home/ubuntu"
EOF
- name: Terraform Init
id: init
run: terraform -chdir=operations/deployment/terraform/aws/ init -backend=false
- name: Terraform Validate
id: validate
run: terraform -chdir=operations/deployment/terraform/aws/ validate
- name: Comment Format Check Result
if: always() && steps.fmt.outcome == 'failure' && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ Terraform formatting issues detected. Run `terraform fmt -recursive operations/deployment/terraform/aws/` to fix.'
})