Skip to content

Commit bba4ee2

Browse files
deploy
1 parent d6425b5 commit bba4ee2

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build and Deploy to DigitalOcean
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build-and-deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
15+
- name: Log in to Docker Hub
16+
uses: docker/login-action@v2
17+
with:
18+
username: ${{ secrets.DOCKERHUB_USERNAME }}
19+
password: ${{ secrets.DOCKERHUB_TOKEN }}
20+
21+
- name: Build and push Docker image
22+
run: |
23+
docker build -t yourusername/yourapp:latest .
24+
docker push yourusername/yourapp:latest
25+
26+
- name: SSH and update on droplet
27+
uses: appleboy/[email protected]
28+
with:
29+
host: ${{ secrets.DO_SSH_HOST }}
30+
username: ${{ secrets.DO_SSH_USER }}
31+
key: ${{ secrets.DO_SSH_KEY }}
32+
script: |
33+
docker pull yourusername/yourapp:latest
34+
cd /root/yourapp
35+
docker compose down
36+
docker compose up -d

docker-compose.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ services:
1313

1414
# 2) Your PHP app service must build from your custom Dockerfile
1515
app:
16-
build:
17-
context: .
18-
dockerfile: Dockerfile
16+
image: utkarshs7/ourawork:latest
1917
restart: unless-stopped
2018
working_dir: /var/www/html
2119
volumes:

0 commit comments

Comments
 (0)