Files
KArtSell.Aegis/.gitea/workflows/deploy.yml
T
kjh2064 30f4858a34
ci / backend (push) Failing after 1s
ci / static (push) Failing after 8s
ci / backend (pull_request) Failing after 2s
ci / static (pull_request) Failing after 11s
Build & Test with Secrets / build (pull_request) Failing after 1s
ci / publish (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / frontend (pull_request) Has been cancelled
ci / publish (pull_request) Has been cancelled
Build & Test with Secrets / security-scan (pull_request) Failing after 8s
Build & Test with Secrets / frontend (pull_request) Successful in 4m42s
Build & Test with Secrets / notification (pull_request) Failing after 1s
AEG-X-004: deploy DbUp migrations with release artifact
2026-08-06 14:46:01 +09:00

95 lines
3.0 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
# DbMigrator publish flattens Content SQL beside the executable.
# Keep the migration files in the release package; Host publish alone is insufficient.
test -f ./publish/0032_shadow_run_queued_status_contract.sql
- name: Create deployment package
run: |
cd ./publish
zip -r ../kartsell-release.zip .
cd ..
ls -lh kartsell-release.zip
- name: Deploy via SCP to server
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
# SSH 키 설정 (SSH_KEY에서 변환)
echo "$DEPLOY_KEY" > /tmp/deploy_key.pem
chmod 600 /tmp/deploy_key.pem
# 서버에 파일 전송
echo "📦 Deploying kartsell-release.zip to server..."
scp -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no \
./kartsell-release.zip kjh2064@178.104.200.7:/tmp/
echo "✅ File transferred"
echo ""
ssh -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no kjh2064@178.104.200.7 \
"export KARTSELL_POSTGRES='${{ secrets.KARTSELL_POSTGRES }}'; \
sudo mkdir -p /app/kartsell/current; \
sudo unzip -oq /tmp/kartsell-release.zip -d /app/kartsell/current; \
cd /app/kartsell/current; \
dotnet KArtSell.DbMigrator.dll; \
sudo systemctl restart kartsell; \
sleep 3; \
systemctl is-active --quiet kartsell"
echo "✅ Artifact deployed, DbMigrator executed, and kartsell restarted"
# Cleanup
rm /tmp/deploy_key.pem
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"