fix(CD): use appleboy ssh action
This commit is contained in:
@@ -10,26 +10,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest # The runner environment for this job
|
runs-on: ubuntu-latest # The runner environment for this job
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Deploy via ssh
|
||||||
uses: actions/checkout@v4 # Action to checkout your repository code
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
|
||||||
- name: Set up SSH
|
|
||||||
uses: webfactory/ssh-agent@v0.9.0 # Action to set up SSH agent
|
|
||||||
with:
|
with:
|
||||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} # Your server's SSH private key
|
host: ${{ secrets.SSH_SERVER }}
|
||||||
|
username: ${{ secrets.SSH_USER }}
|
||||||
- name: Add Server to Known Hosts
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
run: |
|
script: |
|
||||||
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'
|
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
cd ~/cover-letter # Replace with your project's path on the server
|
cd ~/cover-letter
|
||||||
git pull # or your branch
|
git pull
|
||||||
sudo docker compose down
|
sudo docker compose down
|
||||||
sudo docker compose up -d --build
|
sudo docker compose up -d --build
|
||||||
EOF
|
|
||||||
|
|||||||
Reference in New Issue
Block a user