Skip to content

Merge pull request #12 from nishit-srivastava/2023ac05362 #25

Merge pull request #12 from nishit-srivastava/2023ac05362

Merge pull request #12 from nishit-srivastava/2023ac05362 #25

Workflow file for this run

name: CI Pipeline
on:
workflow_dispatch:
push:
branches:
- main
- 2023ac05362
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # Needed to push back updated VERSION file
if: >
github.ref == 'refs/heads/main' ||
(github.ref == 'refs/heads/2023ac05362' &&
contains(join(github.event.commits.*.added, ','), '.pkl') ||
contains(join(github.event.commits.*.modified, ','), '.pkl') )
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./app/api/requirements.txt
pip install flake8 pytest
- name: Run linter (flake8)
run: flake8 ./app --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Increment version
id: version
run: |
if [ ! -f VERSION ]; then
echo "1.0" > VERSION
fi
VERSION=$(cat VERSION)
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
MINOR=$((MINOR + 1))
NEW_VERSION="${MAJOR}.${MINOR}"
echo $NEW_VERSION > VERSION
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Commit updated version
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add VERSION
git commit -m "chore: bump version to ${{ env.VERSION }}"
git push
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./app/api
file: ./docker/Dockerfile
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/mlops-flask-api:latest
${{ secrets.DOCKER_USERNAME }}/mlops-flask-api:${{ env.VERSION }}