name: Deploy SingleChat on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest env: SSH_HOST: ${{ vars.SSH_HOST }} SSH_PORT: ${{ vars.SSH_PORT }} SSH_USER: ${{ vars.SSH_USER }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Show resolved non-secret config run: | echo "SSH_HOST=$SSH_HOST" echo "SSH_PORT=$SSH_PORT" echo "SSH_USER=$SSH_USER" test -n "$SSH_HOST" test -n "$SSH_PORT" test -n "$SSH_USER" echo "DEPLOY_SCRIPT=/usr/local/bin/actualize-singlechat.sh" - name: Prepare SSH run: | set -e mkdir -p ~/.ssh printf '%s' "${{ secrets.PROD_SSH_KEY_B64 }}" | base64 -d > ~/.ssh/id_deploy chmod 600 ~/.ssh/id_deploy ssh-keyscan -p "$SSH_PORT" "$SSH_HOST" >> ~/.ssh/known_hosts - name: Test SSH connection run: | set -e ssh -i ~/.ssh/id_deploy \ -o StrictHostKeyChecking=no \ -o BatchMode=yes \ -o ConnectTimeout=10 \ -p "$SSH_PORT" \ "$SSH_USER@$SSH_HOST" \ "echo SSH OK" - name: Install deployment script run: | set -e scp -i ~/.ssh/id_deploy \ -o StrictHostKeyChecking=no \ -o BatchMode=yes \ -o ConnectTimeout=10 \ -P "$SSH_PORT" \ scripts/actualize-singlechat.sh \ "$SSH_USER@$SSH_HOST:/tmp/actualize-singlechat.sh" ssh -i ~/.ssh/id_deploy \ -o StrictHostKeyChecking=no \ -o BatchMode=yes \ -o ConnectTimeout=10 \ -p "$SSH_PORT" \ "$SSH_USER@$SSH_HOST" \ "sudo install -m 755 /tmp/actualize-singlechat.sh /usr/local/bin/actualize-singlechat.sh" - name: Run deployment script run: | set -e ssh -i ~/.ssh/id_deploy \ -o StrictHostKeyChecking=no \ -o BatchMode=yes \ -o ConnectTimeout=10 \ -p "$SSH_PORT" \ "$SSH_USER@$SSH_HOST" \ "sudo /usr/local/bin/actualize-singlechat.sh"