-
Notifications
You must be signed in to change notification settings - Fork 1.4k
214 lines (198 loc) · 6.63 KB
/
build_apps.yml
File metadata and controls
214 lines (198 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
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}}