Skip to content

fix(ci): wrong image name #40

fix(ci): wrong image name

fix(ci): wrong image name #40

Workflow file for this run

name: ML Pipeline
on:
push:
env:
AZURE_RESOURCE_GROUP: "degradai-cpr"
AZURE_WORKSPACE: "azure-ml-cpr"
AZURE_LOCATION: "northeurope"
AZURE_TAGS: "{}"
PYTHON_VERSION: "3.10.15"
DOCKER_REGISTRY: "ghcr.io"
AZURE_WEBAPP_NAME: "degradai-api"
permissions:
contents: write
jobs:
unit-test:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install --with dev
- name: Run tests
run: poetry run pytest tests/unit/
ml-pipeline:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
environment: degradai
needs: unit-test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Install Azure CLI ML extension
run: az extension add --name ml
- name: setup azure
working-directory: train
run: ./setup_AzureML.sh ${{ secrets.AZURE_SUBSCRIPTION_ID }} ${{ env.AZURE_RESOURCE_GROUP }} ${{ env.AZURE_WORKSPACE }} ${{ env.AZURE_LOCATION }}
- name: Run pipeline
working-directory: train
run: ./run_AzureML.sh ${{ secrets.AZURE_SUBSCRIPTION_ID }} ${{ env.AZURE_RESOURCE_GROUP }} ${{ env.AZURE_WORKSPACE }} ${{ env.AZURE_LOCATION }} ${{ env.AZURE_TAGS }}
- name: Download model
working-directory: train
env:
DOWNLOAD_PATH: "../app"
run: |
MODEL_VERSION=$(cat ../app/model/model_version)
./run_download_model.sh $MODEL_VERSION ${{ env.AZURE_RESOURCE_GROUP }} ${{ env.AZURE_WORKSPACE }} ${{ env.AZURE_LOCATION }} ${{ secrets.AZURE_SUBSCRIPTION_ID }} ${{ env.DOWNLOAD_PATH }}
- name: Check app folder
run: ls app/model
- name: Create bump and changelog
id: cz
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GIT_TOKEN }}
changelog_increment_filename: body.md
push: true
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: body.md
tag_name: ${{ env.REVISION }}
files: app/model/degradai.keras
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
integration-test:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
environment: degradai
needs: ml-pipeline
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install --with dev
- name: azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Install Azure CLI ML extension
run: az extension add --name ml
- name: Download latest model
working-directory: train
env:
DOWNLOAD_PATH: "../app"
run: ./run_download_model.sh latest ${{ env.AZURE_RESOURCE_GROUP }} ${{ env.AZURE_WORKSPACE }} ${{ env.AZURE_LOCATION }} ${{ secrets.AZURE_SUBSCRIPTION_ID }} ${{ env.DOWNLOAD_PATH }}
- name: Run tests
run: poetry run pytest tests/integration/
build-deploy-image:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
environment: degradai
needs: integration-test
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Install Azure CLI ML extension
run: az extension add --name ml
- name: Download latest model
working-directory: train
env:
DOWNLOAD_PATH: "../app"
run: ./run_download_model.sh latest ${{ env.AZURE_RESOURCE_GROUP }} ${{ env.AZURE_WORKSPACE }} ${{ env.AZURE_LOCATION }} ${{ secrets.AZURE_SUBSCRIPTION_ID }} ${{ env.DOWNLOAD_PATH }}
- name: Build docker image
run: |
MODEL_VERSION=$(cat app/model/model_version)
docker build -f api.Dockerfile --platform linux/amd64 -t degradai:$MODEL_VERSION .
- name: Tag docker image
run: |
MODEL_VERSION=$(cat app/model/model_version)
docker tag degradai:$MODEL_VERSION ${{ env.DOCKER_REGISTRY }}/patacoing/degradai:$MODEL_VERSION
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GIT_TOKEN }}
- name: Push docker image
run: |
MODEL_VERSION=$(cat app/model/model_version)
docker push ${{ env.DOCKER_REGISTRY }}/patacoing/degradai:$MODEL_VERSION
deploy-to-azure:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
environment: degradai
# needs: build-deploy-image
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GIT_TOKEN }}
- name: azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Deploy container
run: az container create --resource-group ${{ env.AZURE_RESOURCE_GROUP}} --name ${{ env.AZURE_WEBAPP_NAME }} --dns-name-label ${{ env.AZURE_WEBAPP_NAME }} --image ${{ env.DOCKER_REGISTRY }}/patacoing/degradai --ports 8000