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: |
|
run: |
|
||||||
echo "🔧 Preparing database environment..."
|
echo "🔧 Preparing database environment..."
|
||||||
|
|
||||||
# QUANTENGINE_DB_PASSWORD: 미설정 시 빈 문자열로 처리 (pg_hba.conf trust 모드 대응)
|
# QUANTENGINE_DB_PASSWORD: 미설정 시 빈 문자열로 처리
|
||||||
DB_PASSWORD="${{ secrets.QUANTENGINE_DB_PASSWORD }}"
|
DB_PASSWORD="${{ secrets.QUANTENGINE_DB_PASSWORD }}"
|
||||||
if [ -z "$DB_PASSWORD" ]; then
|
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
|
fi
|
||||||
|
|
||||||
if [ -z "${{ env.QUANTENGINE_DB_NAME }}" ] || [ -z "${{ env.QUANTENGINE_DB_USER }}" ]; then
|
if [ -z "${{ env.QUANTENGINE_DB_NAME }}" ] || [ -z "${{ env.QUANTENGINE_DB_USER }}" ]; then
|
||||||
@@ -152,7 +152,7 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 환경 파일 생성
|
# 1) 환경 파일 생성 (.env)
|
||||||
mkdir -p ./deploy
|
mkdir -p ./deploy
|
||||||
printf 'ConnectionStrings__DefaultConnection=Host=127.0.0.1;Database=%s;Username=%s;Password=%s;Search Path=quantengine;\n' \
|
printf 'ConnectionStrings__DefaultConnection=Host=127.0.0.1;Database=%s;Username=%s;Password=%s;Search Path=quantengine;\n' \
|
||||||
"${{ env.QUANTENGINE_DB_NAME }}" \
|
"${{ env.QUANTENGINE_DB_NAME }}" \
|
||||||
@@ -160,13 +160,24 @@ jobs:
|
|||||||
"$DB_PASSWORD" > ./deploy/quantengine.env
|
"$DB_PASSWORD" > ./deploy/quantengine.env
|
||||||
chmod 600 ./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
|
if [ ! -f ./deploy/quantengine.env ] || [ ! -f ./publish/appsettings.Production.json ]; then
|
||||||
echo "❌ Failed to create database config file"
|
echo "❌ Failed to create database config files"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✓ Database configuration prepared"
|
echo "✓ Database configuration prepared (env and appsettings.Production.json)"
|
||||||
|
|
||||||
- name: Package Artifact
|
- name: Package Artifact
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user