Skip to content

Commit 92b8385

Browse files
mapedersenclaude
andcommitted
security: implement secure environment variable management
- Auto-generate .env.production on VPS from GitHub secrets during deployment - Remove local .env.production file (no longer needed) - Secrets now only exist in GitHub (encrypted) and VPS (runtime only) - Eliminates risk of local secret exposure - Ensures fresh configuration on every deployment 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a9547de commit 92b8385

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/pipeline.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,41 @@ jobs:
387387
NEW_COMMIT=$(git rev-parse HEAD)
388388
echo "📌 Deploying commit: $NEW_COMMIT"
389389
390+
# Auto-generate .env.production from GitHub secrets (secure approach)
391+
echo "🔧 Generating secure environment configuration..."
392+
cat > .env.production << EOF
393+
# Auto-generated from GitHub Secrets - $(date -u)
394+
ASPNETCORE_ENVIRONMENT=Production
395+
396+
# Database Configuration
397+
POSTGRES_DB=modernapi_prod
398+
POSTGRES_USER=postgres
399+
POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
400+
DATABASE_CONNECTION=${{ secrets.DATABASE_CONNECTION }}
401+
402+
# Redis Configuration
403+
REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
404+
405+
# JWT Authentication
406+
JWT_SECRET=${{ secrets.JWT_SECRET }}
407+
JWT_ISSUER=ModernAPI
408+
JWT_AUDIENCE=ModernAPI.Users
409+
JWT_EXPIRY_MINUTES=60
410+
411+
# CORS & API Configuration
412+
CORS_ORIGINS=https://${{ secrets.DOMAIN }}
413+
API_BASE_URL=https://${{ secrets.DOMAIN }}
414+
415+
# Production Security Settings
416+
ENABLE_SWAGGER=false
417+
ENABLE_DETAILED_ERRORS=false
418+
ENABLE_SENSITIVE_DATA_LOGGING=false
419+
LOG_LEVEL=Warning
420+
ENABLE_HSTS=true
421+
HTTPS_REDIRECT=true
422+
EOF
423+
echo "✅ Environment configuration generated from secure secrets"
424+
390425
# Backup current containers (for quick rollback)
391426
echo "🔄 Backing up current containers..."
392427
docker compose -f docker-compose.production.yml ps --format "table {{.Service}}\t{{.Status}}" > .container-status-backup || true

0 commit comments

Comments
 (0)