-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (38 loc) · 1.41 KB
/
diareat_ocr_cicd.yml
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
46
47
48
49
name: Diareat OCR CI/CD
on:
push:
branches: [ "main" ]
jobs:
CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker login
uses: docker/[email protected]
with:
username: synoti21
password: ${{ secrets.DOCKERHUB_TOKEN }}
logout: true
- name: Build and push to DockerHub
run: |
docker build -t diareat_ocr .
docker tag diareat_ocr:latest synoti21/diareat_ocr:latest
docker push synoti21/diareat_ocr:latest
CD:
needs: CI
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2 / Check bot status
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | sudo docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
sudo docker rm $(sudo docker stop $(sudo docker ps -a -q --filter ancestor=synoti21/diareat_ocr:latest --format="{{.ID}}"))
sudo docker rmi synoti21/diareat_ocr:latest
sudo docker pull synoti21/diareat_ocr:latest
sudo docker run -d -p 8000:8000 --name diareat_ocr --runtime=nvidia --gpus=all synoti21/diareat_ocr:latest
sleep 10s
sudo docker ps | grep synoti21/diareat_ocr:latest