-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (36 loc) · 1.08 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: CI/CD Pipeline
on:
push:
branches:
- main # Trigger the workflow when pushing to the main branch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Deploy using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
if [ -d "ornatewall-server-app" ]; then
echo "Repository exists. Pulling latest changes..."
cd ornatewall-server-app
git reset --hard
git pull origin main
else
echo "Cloning repository..."
git clone https://github.com/akhilsharmaa/ornatewall-server-app.git
cd ornatewall-server-app
fi
sudo docker-compose down || true
sudo docker-compose pull
sudo docker-compose up --build -d