81119c9fcf
ci / backend (push) Failing after 1s
ci / static (push) Failing after 7s
Build & Test with Secrets / build (push) Failing after 1s
Build & Test with Secrets / security-scan (push) Has been cancelled
Build & Test with Secrets / notification (push) Has been cancelled
Build & Test with Secrets / frontend (push) Has been cancelled
ci / publish (push) Has been cancelled
ci / frontend (push) Has been cancelled
deploy / deploy (push) Successful in 1m29s
deploy / notify (push) Successful in 1s
- Publish both Host and DbMigrator - Skip systemd (Docker env doesn't support it) - Provide manual post-deploy steps Deploy workflow: 1. Gitea Actions: Build + publish to /app/kartsell 2. Manual on server: Run migrations + restart service Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
99 lines
3.2 KiB
YAML
99 lines
3.2 KiB
YAML
name: deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
deploy:
|
|
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '10.0.x'
|
|
|
|
- run: dotnet restore KArtSell.sln
|
|
|
|
- run: dotnet build KArtSell.sln --no-restore -c Release
|
|
|
|
- name: Publish Release Build
|
|
run: |
|
|
dotnet publish -c Release -o ./publish src/KArtSell.Host
|
|
dotnet publish -c Release -o ./publish src/KArtSell.DbMigrator
|
|
|
|
- name: Deploy to Gitea server (local filesystem)
|
|
env:
|
|
KARTSELL_POSTGRES: ${{ secrets.KARTSELL_POSTGRES }}
|
|
KRX_OPENAPI: ${{ secrets.KRX_OPENAPI }}
|
|
OPENDART_API: ${{ secrets.OPENDART_API }}
|
|
KIS_APP_KEY: ${{ secrets.KIS_APP_KEY }}
|
|
KIS_APP_SECRET: ${{ secrets.KIS_APP_SECRET }}
|
|
run: |
|
|
# Gitea 서버 동일 파일시스템으로 배포
|
|
DEPLOY_PATH="/app/kartsell"
|
|
|
|
echo "📦 Deploying to $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)"
|
|
sudo mv "$DEPLOY_PATH/current" "$BACKUP_DIR"
|
|
echo "✅ Backed up previous version to $BACKUP_DIR"
|
|
fi
|
|
|
|
# 새 버전 배포
|
|
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"
|
|
|
|
echo "✅ Release build deployed to $DEPLOY_PATH/current"
|
|
echo ""
|
|
echo "📋 Next steps on server:"
|
|
echo " 1. SSH: ssh kjh2064@178.104.200.7"
|
|
echo " 2. Migrate: cd $DEPLOY_PATH/current && export KARTSELL_POSTGRES='$KARTSELL_POSTGRES' && dotnet KArtSell.DbMigrator.dll"
|
|
echo " 3. Restart: sudo systemctl restart kartsell"
|
|
echo " 4. Check: curl https://kartsell.taxbaik.com/"
|
|
echo ""
|
|
echo "✅ Deployment completed"
|
|
|
|
notify:
|
|
if: always()
|
|
needs: deploy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Notify deployment status
|
|
env:
|
|
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
|
|
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
run: |
|
|
STATUS="${{ needs.deploy.result }}"
|
|
if [ "$STATUS" = "success" ]; then
|
|
MESSAGE="✅ K-ArtSell Aegis deployed successfully to production"
|
|
else
|
|
MESSAGE="❌ K-ArtSell Aegis deployment failed"
|
|
fi
|
|
|
|
curl -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage" \
|
|
-d "chat_id=$TELEGRAM_CHAT_ID" \
|
|
-d "text=$MESSAGE" \
|
|
-d "parse_mode=HTML" || echo "Telegram notification failed"
|