Skip to content

Deploy to Remote Host #8

Deploy to Remote Host

Deploy to Remote Host #8

Workflow file for this run

name: Deploy to Remote Host
on:
workflow_run:
workflows: ["Vite.js CI"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa || { echo "Failed to write SSH key"; exit 1; }
chmod 600 ~/.ssh/id_rsa || { echo "Failed to set permissions"; exit 1; }
ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.REMOTE_HOST_IP }} >> ~/.ssh/known_hosts || { echo "Failed to add host"; exit 1; }
- name: Execute script on remote host
run: |
ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} root@${{ secrets.REMOTE_HOST_IP }} 'cd /root/scripts && bash ./deploy.sh'