Build main by @alexkuzmik #9
This file contains 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: "Build Opik Docker Images" | |
run-name: "Build ${{ github.ref_name }} by @${{ github.actor }}" | |
on: | |
push: | |
branches: | |
- 'main' | |
paths-ignore: | |
- "deployment/**" | |
- 'sdks/**' | |
workflow_dispatch: | |
workflow_call: | |
inputs: | |
version: | |
type: string | |
required: true | |
description: Version | |
default: "" | |
jobs: | |
set-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
build_from: ${{ steps.version.outputs.build_from }} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- 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 }} | |
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.version}}" == "" ]]; then | |
echo "build_from=${{github.ref_name}}" | tee -a $GITHUB_OUTPUT | |
else | |
echo "build_from=${{inputs.version}}" | tee -a $GITHUB_OUTPUT | |
fi | |
echo "Build from: " | |
build-backend: | |
needs: | |
- set-version | |
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: "" | |
build-frontend: | |
needs: | |
- set-version | |
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: true | |
comet_build_args: "BUILD_MODE=comet" | |
create-git-tag: | |
if: github.ref_name == 'main' | |
needs: | |
- set-version | |
- build-backend | |
- build-frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Create git tag | |
run: | | |
set -x | |
git config --local user.email "[email protected]" | |
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}} | |