-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (84 loc) · 3.5 KB
/
cicd.yaml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# .github/workflows/cicd.yml
# - CICD (major)
# - multiple connected jobs (with if successfully) --- done
# - pull prod model from RDS and create container --- done
# - push to ECR ---
# - Run the container on EC2/ECS ---
# - push docker img to docker hub and run it on docker desktop --- done
# - or push particular branch k particular folder me hone pr CI pipeline trigger karo --- done
name: cicd pipeline
on:
push:
branches:
- main
paths: # if any changes detected in below dir then runner'll trigger cicd pipeline
- ./src/**
- .github/**
- ./prod/**
- Dockerfile
- docker_requirements.txt
pull_request:
branches:
- main
jobs:
download_model:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install AWS CLI # install aws cli in runner space
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Configure AWS CLI # configure aws cli so that we can access there services via cmd line or scripts
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws configure set region ${{ secrets.AWS_REGION }}
- name: Install Utilities # install utilities required to fetch model from backend
run: |
python -m pip install --upgrade pip
if [ -f model_requirements.txt ]; then pip install -r model_requirements.txt; fi
- name: Fetch Model From Mlflow # below script will executed and fetch the prod model
run: |
python ./prod/mlflowdb.py ${{ secrets.TRACKING_URI }}
- name: Upload Model Artifact # save the artifacts so that we can utilise it in next stage
uses: actions/upload-artifact@v2
with:
name: model
path: |
/home/runner/work/cicd/cicd/model.joblib
/home/runner/work/cicd/cicd/model_details.json
- name: Print Current Directory # for debuging purpoer, u can remove it
run: ls /home/runner/work/cicd/cicd
build_push_docker_image:
needs: download_model # previous stage must be successfully completed (job dependency)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Print Current Directory be-down # for debug purpose
run: ls /home/runner/work/cicd/cicd
- name: Download Model Artifacts # download the previously saved artifacts
uses: actions/download-artifact@v2
with:
name: model
path: /home/runner/work/cicd/cicd
- name: Print Current Directory af-down # for debugging
run: ls /home/runner/work/cicd/cicd
- name: Build Docker Image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/wineqcicd:v1.0 .
- name: Log-in to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker Img # push the previously built img to dockerhub
run: docker push ${{ secrets.DOCKER_USERNAME }}/wineqcicd:v1.0
deploy:
needs: build_push_docker_image
runs-on: ubuntu-latest
steps:
- name: Deploy the container
env:
deploy_url: ${{ secrets.DEPLOY_HOOK }}
run: |
curl "$deploy_url"