File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Java CI + Docker Publish Pipeline
1+ name : Java CI + Docker Publish Pipeline + Deploy to VPS
22
33on :
44 push :
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
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
You can’t perform that action at this time.
0 commit comments