Skip to content

Build main by @AndreiCautisanu #4691

Build main by @AndreiCautisanu

Build main by @AndreiCautisanu #4691

Workflow file for this run

name: "Build Opik Docker Images"
run-name: "Build ${{ github.ref_name }} by @${{ github.actor }}"
on:
push:
branches:
- 'main'
paths-ignore:
- "deployment/**"
- 'sdks/**'
workflow_dispatch:
inputs:
is_release:
type: boolean
required: true
description: Is release build
default: false
is_adhoc:
type: boolean
required: false
description: Is adhoc build
default: false
build_guardrails:
type: boolean
required: true
description: Build guardrails backend
default: true
workflow_call:
inputs:
version:
type: string
required: true
description: Version
default: ""
is_release:
type: boolean
required: true
description: Is release build
default: false
is_adhoc:
type: boolean
required: false
description: Is adhoc build
default: false
ref:
type: string
required: false
description: Git ref to build from (branch, tag, or commit SHA)
default: ""
build_guardrails:
type: boolean
required: false
description: Build guardrails backend
default: true
outputs:
version:
description: "The version that was built"
value: ${{ jobs.set-version.outputs.version }}
jobs:
set-version:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
version: ${{ steps.version.outputs.version }}
build_from: ${{ steps.version.outputs.build_from }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref }}
- name: Set version
id: version
run: |
if [[ "${{inputs.version}}" != "" ]]; then
VERSION=${{inputs.version}}
else
BASE_VERSION=$(cat version.txt)
BRANCH_NAME="${{ github.ref_name }}"
if [[ "${BRANCH_NAME}" == "main" ]]; then
VERSION=${BASE_VERSION}-${{ github.run_number }}
elif [[ "${BRANCH_NAME}" =~ ^hotfix/.* ]]; then
# Special handling for hotfix branches
VERSION="${BASE_VERSION}-hotfix.${{ github.run_number }}"
else
# Normalize branch name
fixedBranchName=$(echo "${BRANCH_NAME}" | sed 's/origin\///; s/\//-/g; s/_/-/g; s/.*/\L&/')
if [ ${#fixedBranchName} -gt 21 ]; then
fixedBranchName="${fixedBranchName:0:20}"
# remove dash at the end
while [ "${fixedBranchName: -1}" = "-" ]; do
fixedBranchName="${fixedBranchName%?}"
done
fi
VERSION="${BASE_VERSION}-${fixedBranchName}-${{ github.run_number }}"
fi
fi
echo "version=${VERSION}" | tee -a $GITHUB_OUTPUT
echo "Version is ${VERSION}" >> $GITHUB_STEP_SUMMARY
if [ "${{inputs.ref}}" != "" ]; then
echo "build_from=${{inputs.ref}}" | tee -a $GITHUB_OUTPUT
elif [[ "${{inputs.version}}" == "" ]]; then
echo "build_from=${{github.ref_name}}" | tee -a $GITHUB_OUTPUT
else
echo "build_from=${{inputs.version}}" | tee -a $GITHUB_OUTPUT
fi
build-backend:
needs:
- set-version
secrets: inherit
uses: ./.github/workflows/build_and_push_docker.yaml
with:
image: "opik-backend"
version: ${{needs.set-version.outputs.version}}
build_from: ${{needs.set-version.outputs.build_from}}
build_comet_image: false
comet_build_args: ""
is_release: ${{ inputs.is_release || false }}
is_adhoc: ${{ inputs.is_adhoc || false }}
build-sandbox-executor-python:
if: ${{ !inputs.is_adhoc }}
needs:
- set-version
secrets: inherit
uses: ./.github/workflows/build_and_push_docker.yaml
with:
image: "opik-sandbox-executor-python"
version: ${{needs.set-version.outputs.version}}
build_from: ${{needs.set-version.outputs.build_from}}
build_comet_image: false
comet_build_args: ""
is_release: ${{ inputs.is_release || false }}
is_adhoc: ${{ inputs.is_adhoc || false }}
build-python-backend:
if: always() && needs.set-version.result == 'success'
needs:
- set-version
- build-sandbox-executor-python
secrets: inherit
uses: ./.github/workflows/build_and_push_docker.yaml
with:
image: "opik-python-backend"
version: ${{needs.set-version.outputs.version}}
build_from: ${{needs.set-version.outputs.build_from}}
build_comet_image: false
comet_build_args: ""
is_release: ${{ inputs.is_release || false }}
is_adhoc: ${{ inputs.is_adhoc || false }}
# build-guardrails-backend:
# if: inputs.build_guardrails != false
# needs:
# - set-version
# secrets: inherit
# uses: ./.github/workflows/build_and_push_docker.yaml
# with:
# image: "opik-guardrails-backend"
# version: ${{needs.set-version.outputs.version}}
# build_from: ${{needs.set-version.outputs.build_from}}
# build_comet_image: false
# comet_build_args: ""
# is_release: ${{ inputs.is_release || false }}
build-frontend:
needs:
- set-version
secrets: inherit
uses: ./.github/workflows/build_and_push_docker.yaml
with:
image: "opik-frontend"
version: ${{needs.set-version.outputs.version}}
build_from: ${{needs.set-version.outputs.build_from}}
build_comet_image: ${{ !inputs.is_adhoc }}
comet_build_args: ${{ !inputs.is_adhoc && 'BUILD_MODE=comet' || '' }}
is_release: ${{ inputs.is_release || false }}
is_adhoc: ${{ inputs.is_adhoc || false }}
create-git-tag:
if: |
always() &&
!inputs.is_release &&
needs.set-version.result == 'success' &&
needs.build-backend.result == 'success' &&
needs.build-frontend.result == 'success' &&
needs.build-python-backend.result == 'success'
needs:
- set-version
- build-backend
- build-frontend
- build-python-backend
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Create git tag
run: |
set -x
git config --local user.email "github-actions@comet.com"
git config --local user.name "github-actions"
git tag ${{needs.set-version.outputs.version}}
git push --no-verify origin refs/tags/${{needs.set-version.outputs.version}}