From 5d5a546088b1a56ba7f35364c8cf530e7276b895 Mon Sep 17 00:00:00 2001 From: Leons Aleksandrovs <58330666+Skrazzo@users.noreply.github.com> Date: Mon, 14 Jul 2025 13:48:13 +0300 Subject: [PATCH] feat(CD): add CD pipeline workflow --- .github/workflows/deploy.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..9ba5be2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,34 @@ +name: Deploy to Server + +on: + push: + branches: + - main # or 'master', or your preferred branch for deployment + +jobs: + deploy: + 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 + 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 your_server_ip >> ~/.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' + cd ~/cover-letter # Replace with your project's path on the server + git pull origin main # or your branch + docker compose down + docker compose up -d --build + EOF