Skip to content

Build main by @andrescrz #6419

Build main by @andrescrz

Build main by @andrescrz #6419

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
build_arm64:
type: boolean
required: false
description: Build multiarch images
default: true
ai_spend_plugin_ref:
type: string
required: false
description: ai-spend plugin ref
default: "main"
workflow_call:
inputs:
version:
type: string
required: true
description: Version
is_release:
type: boolean
required: true
description: Is release build
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
build_arm64:
type: boolean
required: false
description: Build multiarch images
default: true
ai_spend_plugin_ref:
type: string
required: false
description: ai-spend plugin ref
default: "main"
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@v7
with:
ref: ${{ inputs.ref || github.ref }}
- name: Set version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_REF: ${{ inputs.ref }}
REF_NAME: ${{ github.ref_name }}
RUN_NUMBER: ${{ github.run_number }}
run: |
if [[ "${INPUT_VERSION}" != "" ]]; then
VERSION="${INPUT_VERSION}"
else
BASE_VERSION=$(cat version.txt)
BRANCH_NAME="${REF_NAME}"
if [[ "${BRANCH_NAME}" == "main" ]]; then
VERSION="${BASE_VERSION}-${RUN_NUMBER}"
elif [[ "${BRANCH_NAME}" =~ ^hotfix/.* ]]; then
# Special handling for hotfix branches
VERSION="${BASE_VERSION}-hotfix.${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}-${RUN_NUMBER}"
fi
fi
echo "version=${VERSION}" | tee -a "$GITHUB_OUTPUT"
echo "Version is ${VERSION}" >> "$GITHUB_STEP_SUMMARY"
if [ "${INPUT_REF}" != "" ]; then
echo "build_from=${INPUT_REF}" | tee -a "$GITHUB_OUTPUT"
elif [[ "${INPUT_VERSION}" == "" ]]; then
echo "build_from=${REF_NAME}" | tee -a "$GITHUB_OUTPUT"
else
echo "build_from=${INPUT_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 }}
# push events have no `inputs` context, so force multi-arch there; otherwise honor the input (workflow_dispatch / workflow_call use the declared default: true)
build_arm64: ${{ github.event_name == 'push' || inputs.build_arm64 }}
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_arm64: ${{ github.event_name == 'push' || inputs.build_arm64 }}
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_arm64: ${{ github.event_name == 'push' || inputs.build_arm64 }}
# 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 }}
build_arm64: ${{ github.event_name == 'push' || inputs.build_arm64 }}
ai_spend_plugin_ref: ${{ inputs.ai_spend_plugin_ref || 'main' }}
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@v7
- 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}}