Skip to content

Commit 8f0ef3a

Browse files
authored
Create docker-image.yml
1 parent 50d4241 commit 8f0ef3a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/docker-image.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build and Deploy Docker Services
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Set up SSH
13+
uses: webfactory/ssh-agent@v0.9.0
14+
with:
15+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
16+
17+
- name: Add remote server to known_hosts
18+
run: |
19+
ssh-keyscan ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
20+
21+
- name: Deploy to server
22+
run: |
23+
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'ENDSSH'
24+
# Navigate to project directory
25+
cd ${{ secrets.PROJECT_DIR }}
26+
27+
# Pull latest code
28+
git pull
29+
30+
# Build and restart services using docker-compose
31+
docker compose build
32+
docker compose up -d
33+
ENDSSH

0 commit comments

Comments
 (0)