fix(ci): dynamically inject appsettings.Production.json with actual DB password into publish artifact to resolve DB authentication failures
This commit is contained in:
@@ -141,10 +141,10 @@ jobs:
|
||||
run: |
|
||||
echo "🔧 Preparing database environment..."
|
||||
|
||||
# QUANTENGINE_DB_PASSWORD: 미설정 시 빈 문자열로 처리 (pg_hba.conf trust 모드 대응)
|
||||
# QUANTENGINE_DB_PASSWORD: 미설정 시 빈 문자열로 처리
|
||||
DB_PASSWORD="${{ secrets.QUANTENGINE_DB_PASSWORD }}"
|
||||
if [ -z "$DB_PASSWORD" ]; then
|
||||
echo "⚠️ QUANTENGINE_DB_PASSWORD not set — using empty password (trust auth mode)"
|
||||
echo "⚠️ QUANTENGINE_DB_PASSWORD not set — using empty password"
|
||||
fi
|
||||
|
||||
if [ -z "${{ env.QUANTENGINE_DB_NAME }}" ] || [ -z "${{ env.QUANTENGINE_DB_USER }}" ]; then
|
||||
@@ -152,7 +152,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 환경 파일 생성
|
||||
# 1) 환경 파일 생성 (.env)
|
||||
mkdir -p ./deploy
|
||||
printf 'ConnectionStrings__DefaultConnection=Host=127.0.0.1;Database=%s;Username=%s;Password=%s;Search Path=quantengine;\n' \
|
||||
"${{ env.QUANTENGINE_DB_NAME }}" \
|
||||
@@ -160,13 +160,24 @@ jobs:
|
||||
"$DB_PASSWORD" > ./deploy/quantengine.env
|
||||
chmod 600 ./deploy/quantengine.env
|
||||
|
||||
# 2) appsettings.Production.json 파일 동적 생성 및 배포 배포 폴더(publish) 반영
|
||||
mkdir -p ./publish
|
||||
cat <<EOF > ./publish/appsettings.Production.json
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Host=127.0.0.1;Database=${{ env.QUANTENGINE_DB_NAME }};Username=${{ env.QUANTENGINE_DB_USER }};Password=${DB_PASSWORD};Search Path=quantengine;"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
chmod 600 ./publish/appsettings.Production.json
|
||||
|
||||
# 파일 검증
|
||||
if [ ! -f ./deploy/quantengine.env ]; then
|
||||
echo "❌ Failed to create database config file"
|
||||
if [ ! -f ./deploy/quantengine.env ] || [ ! -f ./publish/appsettings.Production.json ]; then
|
||||
echo "❌ Failed to create database config files"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ Database configuration prepared"
|
||||
echo "✓ Database configuration prepared (env and appsettings.Production.json)"
|
||||
|
||||
- name: Package Artifact
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user