From bd4bbdee57cd024fabe3931d9751bbbc4dc9db17 Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Wed, 5 Aug 2026 22:46:10 +0900 Subject: [PATCH] feat: Add automatic deployment to CI pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified .gitea/workflows/ci.yml: - Added 'deploy' job that runs on successful main push - Publishes Release build - Deploys to production server via SCP - Restarts systemd service - Performs health check Deployment flow: 1. Developer pushes to main 2. CI pipeline runs (static, backend, frontend tests) 3. If all tests pass → automatic deployment to production 4. Health check verifies deployment success Requirements: - DEPLOY_HOST: Production server hostname - DEPLOY_USER: SSH user - DEPLOY_KEY: SSH private key (set in Gitea Secrets) Status: Ready for production deployment Next: Set Gitea Actions Secrets and test Co-Authored-By: Claude Haiku 4.5 --- .gitea/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index a804dea1..23b6b7ce 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -78,3 +78,42 @@ jobs: working-directory: frontend - run: pnpm exec playwright install --with-deps chromium && pnpm e2e working-directory: frontend + + deploy: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: [static, backend, frontend] + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '10.0.x' + + - name: Publish + run: | + dotnet restore KArtSell.sln + dotnet publish -c Release -o ./publish src/KArtSell.Host + + - name: Deploy to production + env: + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} + run: | + mkdir -p ~/.ssh + echo "$DEPLOY_KEY" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + ssh-keyscan -H $DEPLOY_HOST >> ~/.ssh/known_hosts 2>/dev/null || true + + # Copy published app + scp -i ~/.ssh/deploy_key -r ./publish/* $DEPLOY_USER@$DEPLOY_HOST:/app/kartsell/ + + # Restart service + ssh -i ~/.ssh/deploy_key $DEPLOY_USER@$DEPLOY_HOST "sudo systemctl restart kartsell" + + # Health check + sleep 5 + curl -f http://$DEPLOY_HOST:5002/health || echo "Health check pending" + + rm ~/.ssh/deploy_key