fix(CD): use appleboy ssh action

This commit is contained in:
Leons Aleksandrovs
2025-07-14 15:51:04 +03:00
parent 441901e44c
commit 7ce0a1f107

View File

@@ -10,26 +10,15 @@ jobs:
runs-on: ubuntu-latest # The runner environment for this job
steps:
- name: Checkout code
uses: actions/checkout@v4 # Action to checkout your repository code
- name: Set up SSH
uses: webfactory/ssh-agent@v0.9.0 # Action to set up SSH agent
- name: Deploy via ssh
uses: appleboy/ssh-action@v1.0.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} # Your server's SSH private key
- name: Add Server to Known Hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.SSH_SERVER }} >> ~/.ssh/known_hosts # Replace with your server's IP
chmod 600 ~/.ssh/known_hosts
- name: Deploy via SSH
run: |
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_SERVER }} << 'EOF'
host: ${{ secrets.SSH_SERVER }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
source ~/.bashrc
cd ~/cover-letter # Replace with your project's path on the server
git pull # or your branch
cd ~/cover-letter
git pull
sudo docker compose down
sudo docker compose up -d --build
EOF