-
Notifications
You must be signed in to change notification settings - Fork 55
95 lines (95 loc) · 3.56 KB
/
build-and-push-ui-images.yml
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
name: Build and Push UI and BFF Images
on:
# TODO: Replace pull_request with push before merging!!!
pull_request:
branches:
- 'main'
tags:
- 'v*'
paths:
- 'clients/ui/**'
env:
IMG_ORG: kubeflow
IMG_UI_REPO: model-registry-ui
IMG_BFF_REPO: model-registry-bff
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PWD: ${{ secrets.DOCKERHUB_TOKEN }}
PUSH_IMAGE: true
jobs:
build-image:
runs-on: ubuntu-latest
steps:
# Assign context variable for various action contexts (tag, main, CI)
- name: Assigning tag context
if: github.head_ref == '' && startsWith(github.ref, 'refs/tags/v')
run: echo "BUILD_CONTEXT=tag" >> $GITHUB_ENV
- name: Assigning main context
if: github.head_ref == '' && github.ref == 'refs/heads/main'
run: echo "BUILD_CONTEXT=main" >> $GITHUB_ENV
# checkout branch
- uses: actions/checkout@v4
# set image version
- name: Set main-branch environment
if: env.BUILD_CONTEXT == 'main'
run: |
commit_sha=${{ github.event.after }}
tag=main-${commit_sha:0:7}
echo "VERSION=${tag}" >> $GITHUB_ENV
- name: Set tag environment
if: env.BUILD_CONTEXT == 'tag'
run: |
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Build and Push UI Image
shell: bash
env:
IMG_REPO: ${{ env.IMG_UI_REPO }}
run: ./scripts/build_deploy.sh
- name: Build and Push BFF Image
shell: bash
env:
IMG_REPO: ${{ env.IMG_BFF_REPO }}
run: ./scripts/build_deploy.sh
- name: Tag Latest UI Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_UI_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_UI_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push UI Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=latest ./scripts/build_deploy.sh
- name: Tag Latest BFF Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_BFF_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_BFF_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push BFF Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=latest ./scripts/build_deploy.sh
- name: Tag Main UI Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_UI_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_UI_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push UI Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:main
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=main ./scripts/build_deploy.sh
- name: Tag Main BFF Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_BFF_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_BFF_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push BFF Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:main
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=main ./scripts/build_deploy.sh