-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (36 loc) · 1 KB
/
deploy.yml
File metadata and controls
45 lines (36 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Deploy to EC2 Production
on:
push:
branches: [main]
paths-ignore:
- README.md
- readme.md
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: devaman21/doc-analyzer:${{ github.sha }}
- name: Deploy to EC2
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd /home/ubuntu/doc-analyzer
# Update image tag in .env
sed -i "s/^IMAGE_TAG=.*/IMAGE_TAG=${{ github.sha }}/" .env
docker-compose pull
docker-compose up -d --remove-orphans
docker system prune -f