Skip to content

Commit

Permalink
Update diareat_ocr_cicd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
synoti21 authored Jan 25, 2024
1 parent ed379cd commit 74608f1
Showing 1 changed file with 42 additions and 22 deletions.
64 changes: 42 additions & 22 deletions .github/workflows/diareat_ocr_cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
jobs:

CI:

runs-on: ubuntu-latest

steps:
Expand All @@ -19,32 +18,53 @@ jobs:
username: synoti21
password: ${{ secrets.DOCKERHUB_TOKEN }}
logout: true

- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "::set-output name=version::$VERSION"
- 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
docker build -t synoti21/diareat_ocr:${{ steps.image.outputs.version }} .
docker push synoti21/diareat_ocr:${{ steps.image.outputs.version }}
CD:
needs: CI
runs-on: ubuntu-latest

needs: CI
steps:
- name: Deploy to EC2 / Check bot status
uses: appleboy/[email protected]
- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "::set-output name=version::$VERSION"
- name: Setup Kustomize
uses: imranismail/[email protected]


- name: Checkout kustomize repository
uses: actions/checkout@v3
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
repository: CAUSOLDOUTMEN/Diareat_OCR
ref: main
token: ${{ secrets.ACCESS_TOKEN }}
path: Diareat_OCR


- name: Update Kubernetes resources
run: |
cd Diareat_OCR/k8s/
kustomize edit set image synoti21/${{ secrets.PROJECT_NAME }}=synoti21/${{ secrets.PROJECT_NAME }}:${{ steps.image.outputs.version }}
kustomize build .
- name: Commit and push the updated manifest
run: |
cd Diareat_OCR
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git commit -am ":construction_worker: chore: Update deployment to ${{ github.sha }}"
git push

0 comments on commit 74608f1

Please sign in to comment.