-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ on: | |
jobs: | ||
|
||
CI: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -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 |