check-test-mode.ps1 988 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env pwsh
  2. #
  3. # CI Check Script: Fail build if any application-prod*.yml contains test-mode: true
  4. # Usage: ./check-test-mode.ps1
  5. #
  6. $ErrorActionPreference = "Stop"
  7. # Find all application-prod*.yml files
  8. $prodYamlFiles = Get-ChildItem -Path "$PSScriptRoot/../cfc-backend/src/main/resources/" -Filter "application-prod*.yml" -Recurse
  9. if ($prodYamlFiles.Count -eq 0) {
  10. Write-Host "No application-prod*.yml files found. Skipping check."
  11. exit 0
  12. }
  13. $foundViolation = $false
  14. foreach ($file in $prodYamlFiles) {
  15. $content = Get-Content -Path $file.FullName -Raw
  16. if ($content -match "test-mode:\s*true") {
  17. Write-Error "ERROR: Found test-mode: true in production YAML file: $($file.FullName)"
  18. $foundViolation = $true
  19. }
  20. }
  21. if ($foundViolation) {
  22. Write-Error "Build failed: test-mode: true detected in production profile YAML files."
  23. exit 1
  24. } else {
  25. Write-Host "✅ All application-prod*.yml files are clean (no test-mode: true)."
  26. exit 0
  27. }