Skip to content

Commit

Permalink
ci: automate image build and tag (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lampajr authored Feb 21, 2024
1 parent a77d72a commit ec2c7b1
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 31 deletions.
33 changes: 33 additions & 0 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Create a container build"
description: "This workflow can be used to create a container build from source branches."
inputs:
QUAY_ORG:
description: "Quay organization."
default: "opendatahub"
required: false
IMAGE_REPO:
description: "Quay image repo name."
required: true
IMAGE_TAG:
description: "Quay image tag."
required: true
DOCKERFILE:
description: "Dockerfile."
default: "Dockerfile.redhat"
required: false
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SOURCE_BRANCH }}
path: build
- name: Build image
shell: bash
working-directory: build
env:
DOCKER_IMAGE_REPO: quay.io/${{ inputs.QUAY_ORG }}/${{ inputs.IMAGE_REPO }}
DOCKER_IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
DOCKER_FILE: ${{ inputs.DOCKERFILE }}
run: |
./ml_metadata/tools/docker_server/build_docker_image.sh
51 changes: 51 additions & 0 deletions .github/workflows/build-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build MLMD gRPC Server image for Master branch
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
QUAY_ORG: opendatahub
QUAY_ID: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_PASSWORD }}
MLMD_IMAGE_REPO: mlmd-grpc-server
MLMD_IMAGE_DOCKERFILE: Dockerfile.redhat
SOURCE_BRANCH: master

jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate Tag
shell: bash
id: tags
run: |
commit_sha=${{ github.event.after }}
tag=main-${commit_sha:0:7}
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Build Image
uses: ./.github/actions/build
with:
QUAY_ORG: ${{ env.QUAY_ORG }}
IMAGE_REPO: ${{ env.MLMD_IMAGE_REPO }}
IMAGE_TAG: ${{ steps.tags.outputs.tag }}
DOCKERFILE: ${{ env.MLMD_IMAGE_DOCKERFILE }}
- name: Login to Quay
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ env.QUAY_ID }}
password: ${{ env.QUAY_TOKEN }}
- name: Push Images
env:
IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.MLMD_IMAGE_REPO }}
MAIN_HASH_TAG: ${{ steps.tags.outputs.tag }}
run: |
docker push ${IMG}:${MAIN_HASH_TAG}
docker tag ${IMG}:${MAIN_HASH_TAG} ${IMG}:latest
docker push ${IMG}:latest
docker tag ${IMG}:${MAIN_HASH_TAG} ${IMG}:main
docker push ${IMG}:main
40 changes: 40 additions & 0 deletions .github/workflows/build-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Container Image Build
on:
pull_request:
paths-ignore:
- 'LICENSE*'
- '**.gitignore'
- '**.md'
- '**.txt'
- '.github/ISSUE_TEMPLATE/**'
- '.github/dependabot.yml'
- 'docs/**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
env:
QUAY_ORG: opendatahub
QUAY_ID: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_PASSWORD }}
MLMD_IMAGE_REPO: mlmd-grpc-server
MLMD_IMAGE_DOCKERFILE: Dockerfile.redhat
SOURCE_BRANCH: ${{ github.ref }}
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate Tag
shell: bash
id: tags
run: |
commit_sha=${{ github.event.after }}
tag=main-${commit_sha:0:7}
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Build Image
uses: ./.github/actions/build
with:
QUAY_ORG: ${{ env.QUAY_ORG }}
IMAGE_REPO: ${{ env.MLMD_IMAGE_REPO }}
IMAGE_TAG: ${{ steps.tags.outputs.tag }}
DOCKERFILE: ${{ env.MLMD_IMAGE_DOCKERFILE }}
31 changes: 0 additions & 31 deletions .github/workflows/build.yaml

This file was deleted.

0 comments on commit ec2c7b1

Please sign in to comment.