Fix deploy.yml: Add sudo, create systemd service, set correct port 5002
ci / backend (push) Failing after 1s
ci / static (push) Failing after 6s
Build & Test with Secrets / build (push) Failing after 1s
Build & Test with Secrets / security-scan (push) Has been cancelled
Build & Test with Secrets / frontend (push) Has been cancelled
Build & Test with Secrets / notification (push) Has been cancelled
ci / publish (push) Has been cancelled
ci / frontend (push) Has been cancelled
deploy / deploy (push) Failing after 1m6s
deploy / notify (push) Successful in 1s

Changes:
- Create /app/kartsell with proper permissions
- Backup previous version
- Generate systemd kartsell.service with environment variables
- Start service on port 5002

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-08-05 23:01:35 +09:00
parent 0a5d134848
commit 5e29a3192a
+49 -10
View File
@@ -42,19 +42,24 @@ jobs:
echo "📦 Deploying to $DEPLOY_PATH..."
# 배포 디렉토리 생성
mkdir -p "$DEPLOY_PATH"
# 배포 디렉토리 생성 (sudo 사용)
if [ ! -d "$DEPLOY_PATH" ]; then
sudo mkdir -p "$DEPLOY_PATH"
sudo chown -R $USER:$USER "$DEPLOY_PATH"
echo "✅ Created $DEPLOY_PATH"
fi
# 기존 백업
if [ -d "$DEPLOY_PATH/current" ]; then
BACKUP_DIR="$DEPLOY_PATH/backup-$(date +%s)"
mv "$DEPLOY_PATH/current" "$BACKUP_DIR"
sudo mv "$DEPLOY_PATH/current" "$BACKUP_DIR"
echo "✅ Backed up previous version to $BACKUP_DIR"
fi
# 새 버전 배포
cp -r ./publish "$DEPLOY_PATH/current"
chmod +x "$DEPLOY_PATH/current/KArtSell.Host"
sudo cp -r ./publish "$DEPLOY_PATH/current"
sudo chown -R $USER:$USER "$DEPLOY_PATH/current"
sudo chmod +x "$DEPLOY_PATH/current/KArtSell.Host"
echo "✅ Files deployed successfully"
@@ -71,11 +76,45 @@ jobs:
echo "✅ Migrations completed"
# systemd 서비스 재시작
echo "🔄 Restarting service..."
sudo systemctl restart kartsell || {
echo "⚠️ Service restart completed"
}
# systemd 서비스 생성/활성화 (첫 배포 시)
echo "🔧 Configuring systemd service..."
sudo tee /etc/systemd/system/kartsell.service > /dev/null << 'SYSTEMD_EOF'
[Unit]
Description=K-ArtSell Aegis - Financial Advisory System
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
User=$USER
WorkingDirectory=$DEPLOY_PATH/current
ExecStart=/usr/bin/dotnet KArtSell.Host.dll
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
Environment="ASPNETCORE_ENVIRONMENT=Production"
Environment="ASPNETCORE_URLS=http://127.0.0.1:5002"
Environment="KARTSELL_POSTGRES=$KARTSELL_POSTGRES"
Environment="KRX_OPENAPI=$KRX_OPENAPI"
Environment="OPENDART_API=$OPENDART_API"
Environment="KIS_APP_KEY=$KIS_APP_KEY"
Environment="KIS_APP_SECRET=$KIS_APP_SECRET"
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
SYSTEMD_EOF
sudo systemctl daemon-reload
sudo systemctl enable kartsell
# 서비스 시작/재시작
echo "🔄 Starting service..."
sudo systemctl restart kartsell
# 헬스체크
echo "🏥 Health check..."