name: Deploy via rsync on: push: branches: - release jobs: deploy: runs-on: [ ubuntu-22.04 ] steps: - uses: actions/checkout@v4 - name: Install rsync run: sudo apt-get update -qq && sudo apt-get install -y -qq rsync continue-on-error: true - name: Setup SSH run: | mkdir -p ~/.ssh echo "${{ secrets.SSH_KEY }}" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts 2>/dev/null - name: Rsync to /opt/barotrauma run: | rsync -avz --delete \ --exclude=.git --exclude=.gitea \ -e "ssh -i ~/.ssh/deploy_key" \ ./ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/opt/barotrauma/ - name: Restart server run: | ssh -i ~/.ssh/deploy_key \ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \ "systemctl restart barotrauma 2>/dev/null || \ (killall DedicatedServer 2>/dev/null; sleep 2; cd /opt/barotrauma && nohup ./DedicatedServer >/dev/null 2>&1 &)"