forked from kubeflow/model-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CSI build, tag and push workflow
Signed-off-by: Andrea Lamparelli <[email protected]>
- Loading branch information
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Container image build and tag | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
paths-ignore: | ||
- 'LICENSE*' | ||
- '**.gitignore' | ||
- '**.md' | ||
- '**.txt' | ||
- '.github/ISSUE_TEMPLATE/**' | ||
- '.github/dependabot.yml' | ||
- 'docs/**' | ||
env: | ||
IMG_ORG: kubeflow | ||
IMG_REPO: model-registry-storage-initializer | ||
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKER_PWD: ${{ secrets.DOCKERHUB_TOKEN }} | ||
PUSH_IMAGE: true | ||
jobs: | ||
build-csi-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 | ||
# docker login | ||
- name: Docker login | ||
shell: bash | ||
run: make docker/login | ||
# build & push | ||
- name: Build CSI Image | ||
working-directory: ./csi | ||
shell: bash | ||
env: | ||
IMG_ORG: ${{ env.IMG_ORG }} | ||
IMG_REPO: ${{ env.IMG_REPO }} | ||
IMG_VERSION: ${{ env.VERSION }} | ||
run: | | ||
make docker-build-dev | ||
- name: Push CSI Image | ||
if: env.PUSH_IMAGE == 'true' | ||
shell: bash | ||
env: | ||
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }} | ||
run: IMG=${{ env.IMG }} IMG_VERSION=${{ env.VERSION }} make image/push | ||
# Tag latest and main | ||
- name: Tag Latest | ||
if: env.BUILD_CONTEXT == 'main' && env.PUSH_IMAGE == 'true' | ||
shell: bash | ||
env: | ||
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }} | ||
run: | | ||
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest | ||
IMG=${{ env.IMG }} IMG_VERSION=latest make image/push | ||
- name: Tag Main | ||
if: env.BUILD_CONTEXT == 'main' && env.PUSH_IMAGE == 'true' | ||
shell: bash | ||
env: | ||
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }} | ||
run: | | ||
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:main | ||
IMG=${{ env.IMG }} IMG_VERSION=main make image/push |