Skip to content

Commit 3e21945

Browse files
authored
Merge pull request #27 from SLUDI/main
Update deployment steps in GitHub Actions workflow
2 parents c4f4843 + 4834ee0 commit 3e21945

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

.github/workflows/deploy.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,35 @@ jobs:
4242
needs: build-and-push
4343

4444
steps:
45-
- name: Wait for build step to finish
46-
run: echo "Deploying to EC2..."
45+
- name: Deploying to EC2
46+
run: echo "Deploying backend app to EC2..."
4747

48-
- name: Execute remote docker-compose update
48+
- name: SSH and deploy backend
4949
uses: appleboy/ssh-action@v0.1.8
5050
with:
5151
host: ${{ secrets.EC2_HOST }}
5252
username: ${{ secrets.EC2_USER }}
5353
key: ${{ secrets.SSH_PRIVATE_KEY }}
5454
port: ${{ secrets.SSH_PORT || '22' }}
5555
script: |
56-
# make sure docker is available
56+
# Check docker is available
5757
docker --version || exit 1
58+
59+
# Go to backend directory
5860
cd ${{ env.REMOTE_DIR }} || exit 1
59-
# optionally show docker-compose file
61+
6062
echo "docker-compose.yml located at $(pwd)/docker-compose.yml"
61-
# pull the latest image and recreate containers
63+
64+
# Stop and remove existing containers
65+
docker-compose down
66+
67+
# Pull the latest image
6268
docker-compose pull || docker pull ${{ env.IMAGE_NAME }}:latest
69+
70+
# Recreate and start containers
6371
docker-compose up -d --build
64-
# optional: prune unused images
72+
73+
# Cleanup unused images
6574
docker image prune -f || true
75+
76+
echo "Backend deployment completed successfully!"

0 commit comments

Comments
 (0)