From 02c8e75f2487c3a881f31fa7b7a57d6563cc2022 Mon Sep 17 00:00:00 2001 From: MaksSlyzar Date: Wed, 1 Apr 2026 01:12:22 +0300 Subject: [PATCH] Setup Github auto-deploy --- .github/workflows/deploy.yml | 39 ++++++++++++++++++++++++++++++++++++ game-server/src/index.js | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..1910157 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Deploy MMO Server + +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Deploy via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.SSH_KEY }} + port: 22 + script: | + cd /home/amp/gso + + git pull origin main + + npm run install-all + + pm2 delete gso-api gso-server || true + + pm2 start /home/amp/gso/api/package.json --name "gso-api" --interpreter node -- run start + + pm2 start /home/amp/gso/game-server/package.json --name "gso-server" --interpreter node -- run start + + cd /home/amp/gso/client && npm run build + + pm2 save + + echo "Deployed!" diff --git a/game-server/src/index.js b/game-server/src/index.js index 748535b..e12dc65 100644 --- a/game-server/src/index.js +++ b/game-server/src/index.js @@ -25,7 +25,7 @@ const server = http.createServer(app); const io = new Server(server, { cors: { - origin: "http://localhost:5173", + origin: "*", methods: ["GET", "POST"], credentials: true, },