26 lines
858 B
PowerShell
26 lines
858 B
PowerShell
#!/usr/bin/env pwsh
|
|
# Encrypts .env to .env.age using the Jannik-Cloud age public key
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$ProjectRoot = Split-Path -Parent $ScriptDir
|
|
$EnvFile = Join-Path $ProjectRoot '.env'
|
|
$EnvAgeFile = Join-Path $ProjectRoot '.env.age'
|
|
$PublicKey = 'age1sa3q5qxl5dylld7v839m9lkv5h7l457wq4h40pt7kfmcfhcqkfjqspdjpn'
|
|
|
|
if (-not (Test-Path $EnvFile)) {
|
|
Write-Error ".env file not found at $EnvFile"
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Encrypting .env -> .env.age ..." -ForegroundColor Green
|
|
age --encrypt -r $PublicKey -o $EnvAgeFile $EnvFile
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "Done. .env.age created successfully." -ForegroundColor Green
|
|
Write-Host "You can now safely commit .env.age to git." -ForegroundColor Yellow
|
|
} else {
|
|
Write-Error "Encryption failed!"
|
|
exit 1
|
|
}
|