From 7ce0a1f1072eaf026ad50fd5a64c91ba325c7398 Mon Sep 17 00:00:00 2001 From: Leons Aleksandrovs <58330666+Skrazzo@users.noreply.github.com> Date: Mon, 14 Jul 2025 15:51:04 +0300 Subject: [PATCH] fix(CD): use appleboy ssh action --- .github/workflows/deploy.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0d38091..755f54a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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