Skip to content

feat:healthcheck API (#197) #78

feat:healthcheck API (#197)

feat:healthcheck API (#197) #78

Workflow file for this run

name: Multiple Server Deployment
on:
push:
branches: ["dev-be"]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Import environment variables
run: |
echo "${{ secrets.ENV_GAME }}" > ./be/gameServer/.env
echo "${{ secrets.ENV_SIGNALING }}" > ./be/signalingServer/.env
echo "${{ secrets.ENV_VOICE }}" > ./be/voiceProcessingServer/.env
shell: bash
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add remote server to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
- name: Transfer files via SCP
run: |
cd be
# Game Server
cd gameServer
zip -r game-server.zip src package.json tsconfig.json tsconfig.build.json nest-cli.json .env
scp -P ${{ secrets.SERVER_PORT }} ./game-server.zip ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/home/${{ secrets.SSH_USER }}/deploy/servers/
cd ..
# Signaling Server
cd signalingServer
zip -r signaling-server.zip src package.json .env
scp -P ${{ secrets.SERVER_PORT }} ./signaling-server.zip ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/home/${{ secrets.SSH_USER }}/deploy/servers/
cd ..
# Voice Processing Server
cd voiceProcessingServer
zip -r voice-server.zip src package.json .env
scp -P ${{ secrets.SERVER_PORT }} ./voice-server.zip ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/home/${{ secrets.SSH_USER }}/deploy/servers/
- name: Execute remote commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
export PATH=$PATH:/home/${{ secrets.SSH_USER }}/.nvm/versions/node/v21.7.3/bin
cd ~/deploy/servers/
# Game Server
if pm2 list | grep -q "game-server"; then
pm2 delete game-server
fi
rm -rf ./game-server
unzip -o game-server.zip -d ./game-server
rm game-server.zip
cd game-server
npm install
npm run build
pm2 start dist/main.js --name game-server
cd ..
# Signaling Server
if pm2 list | grep -q "signaling-server"; then
pm2 delete signaling-server
fi
rm -rf ./signaling-server
unzip -o signaling-server.zip -d ./signaling-server
rm signaling-server.zip
cd signaling-server
npm install
pm2 start src/main.js --name signaling-server
cd ..
# Voice Processing Server
if pm2 list | grep -q "voice-server"; then
pm2 delete voice-server
fi
rm -rf ./voice-server
unzip -o voice-server.zip -d ./voice-server
rm voice-server.zip
cd voice-server
npm install
pm2 start src/main.js --name voice-server
cd ..
pm2 save