Publish docker image to dockerhub #26
This file contains hidden or 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
name: CI Pipeline | |
on: push | |
jobs: | |
project-testing: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v3 | |
- name: setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Cache pip dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: run pipeline | |
env: | |
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }} | |
run: | | |
dvc repro | |
- name: Run model tests | |
env: | |
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }} | |
run: | | |
python -m unittest tests/test_model.py | |
- name: Promote model to production | |
if: success() | |
env: | |
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }} | |
run: python scripts/promote_model.py | |
- name: Run Flask app tests | |
if: success() | |
env: | |
DAGSHUB_PAT: ${{ secrets.DAGSHUB_PAT }} | |
run: python -m unittest tests/test_flask_app.py | |
build-and-deploy: | |
needs: project-testing | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v3 | |
- name: setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Login to Dcokerhub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME}} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN}} | |
- name: Build Docker Image | |
if: success() | |
run: | | |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME}}/text-classification-using-mlops:latest . | |
- name: Push Dcoker image to Dockerhub | |
if: success() | |
run: | | |
docker push ${{ secrets.DOCKER_HUB_USERNAME}}/text-classification-using-mlops:latest | |