@@ -62,23 +62,28 @@ jobs:
6262 runs-on : ubuntu-latest
6363
6464 steps :
65- - name : SSH into VM and redeploy
66- uses : appleboy/ssh-action@master
65+ - name : Deploy with Docker Compose
66+ uses : appleboy/ssh-action@v1.0.3
6767 with :
6868 host : ${{ secrets.VM_HOST }}
6969 username : ${{ secrets.VM_USERNAME }}
7070 key : ${{ secrets.VM_SSH_KEY }}
7171 script : |
72- # Pull the image tagged with the specific branch name (e.g., 'praveshan')
73- docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
72+ # --- DEPLOYMENT SCRIPT ---
7473
75- # Stop and remove the old container to avoid conflicts
76- docker stop my-app-container || true
77- docker rm my-app-container || true
74+ # 1. Navigate to the directory with your docker-compose.yml file.
75+
76+ cd /home/s0lus/praveshan/
7877
79- # Run the new container using the correct image tag
80- docker run -d \
81- --restart always \
82- -p 8080:80 \
83- --name my-app-container \
84- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
78+ # 2. Set the TAG variable for docker-compose to use.
79+ export TAG=${{ github.ref_name }}
80+
81+ # 3. Log in to GitHub Container Registry to pull the private image.
82+ echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
83+
84+ # 4. Pull the latest version of your backend image.
85+ docker pull ghcr.io/amfoss/ammentor-backend:$TAG
86+
87+ # 5. Start the services. Docker Compose will see the new backend
88+ # image and intelligently recreate only that container.
89+ docker-compose up -d
0 commit comments