Skip to content

Commit 9bff2f3

Browse files
Merge pull request #35 from vimal-tech-dev/feature/new-update-phase-10
Fix CI/CD pipeline with deploy job
2 parents 115f34d + 313d8b5 commit 9bff2f3

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Java CI + Docker Publish Pipeline
1+
name: Java CI + Docker Publish Pipeline + Deploy to VPS
22

33
on:
44
push:
@@ -35,7 +35,8 @@ jobs:
3535
runs-on: ubuntu-latest
3636

3737
steps:
38-
- uses: actions/checkout@v4
38+
- name: Checkout source code
39+
uses: actions/checkout@v4
3940

4041
- name: Log in to GHCR
4142
uses: docker/login-action@v3
@@ -50,4 +51,23 @@ jobs:
5051
5152
- name: Push Docker image
5253
run: |
53-
docker push ghcr.io/vimal-java-dev/vimaltech-contact-api:latest
54+
docker push ghcr.io/vimal-java-dev/vimaltech-contact-api:latest
55+
56+
deploy:
57+
# ✅ CRITICAL CONDITION (owner repo only)
58+
if: github.event_name == 'push' && github.repository == 'vimal-java-dev/vimaltech-contact-api'
59+
needs: docker
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Deploy to VPS via SSH
64+
uses: appleboy/ssh-action@v1.0.3
65+
with:
66+
host: ${{ secrets.VPS_HOST }}
67+
username: ${{ secrets.VPS_USER }}
68+
key: ${{ secrets.VPS_SSH_KEY }}
69+
script: |
70+
cd ~/deployments/contact-api
71+
docker pull ghcr.io/vimal-java-dev/vimaltech-contact-api:latest
72+
docker compose up -d
73+
docker image prune -f

0 commit comments

Comments
 (0)