Skip to content

Commit

Permalink
Add the CI to build multi-platform container images
Browse files Browse the repository at this point in the history
Signed-off-by: tenzen-y <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed Sep 17, 2022
1 parent e02eb6e commit caa7b8b
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 66 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build-and-publish-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Reusable workflows for publishing Katib images.
name: Build And Publish Images

on:
workflow_call:
inputs:
component-name:
required: true
type: string
dockerfile:
required: true
type: string
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false

jobs:
build-and-push:
name: Publish Image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker Login
# Trigger workflow only for kubeflow/katib repository with specific branch (master, release-.*) or tag (v.*).
if: >-
github.repository == 'kubeflow/katib' &&
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish Component ${{ inputs.component-name }}
# Trigger workflow only for kubeflow/katib repository with specific branch (master, release-.*) or tag (v.*).
if: >-
github.repository == 'kubeflow/katib' &&
(github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/v'))
id: publish
uses: ./.github/workflows/template-publish-image
with:
image: docker.io/kubeflowkatib/${{ inputs.component-name }}
dockerfile: ${{ inputs.dockerfile }}
push: true

- name: Test Build For Component ${{ inputs.component-name }}
if: steps.publish.outcome == 'skipped'
uses: ./.github/workflows/template-publish-image
with:
image: docker.io/kubeflowkatib/${{ inputs.component-name }}
dockerfile: ${{ inputs.dockerfile }}
push: false
1 change: 0 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ jobs:

- name: Check YAML
run: make yamllint

28 changes: 9 additions & 19 deletions .github/workflows/publish-algorithm-images.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
name: Publish AutoML Algorithm Images

on:
push:
branches:
- master

env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- push
- pull_request

jobs:
algorithm:
name: Publish Image
# Trigger workflow only for kubeflow/katib repository.
if: github.repository == 'kubeflow/katib'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Publish Component ${{ matrix.component-name }}
uses: ./.github/workflows/template-publish-image
with:
image: docker.io/kubeflowkatib/${{ matrix.component-name }}
dockerfile: ${{ matrix.dockerfile }}
uses: ./.github/workflows/build-and-publish-images.yaml
with:
component-name: ${{ matrix.component-name }}
dockerfile: ${{ matrix.dockerfile }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

strategy:
fail-fast: false
Expand Down
27 changes: 9 additions & 18 deletions .github/workflows/publish-core-images.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
name: Publish Katib Core Images

on:
push:
branches:
- master

env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- push
- pull_request

jobs:
core:
name: Publish Image
# Trigger workflow only for kubeflow/katib repository.
if: github.repository == 'kubeflow/katib'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: ./.github/workflows/build-and-publish-images.yaml
with:
component-name: ${{ matrix.component-name }}
dockerfile: ${{ matrix.dockerfile }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish Component ${{ matrix.component-name }}
uses: ./.github/workflows/template-publish-image
with:
image: docker.io/kubeflowkatib/${{ matrix.component-name }}
dockerfile: ${{ matrix.dockerfile }}

strategy:
fail-fast: false
Expand Down
28 changes: 9 additions & 19 deletions .github/workflows/publish-trial-images.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
name: Publish Trial Images

on:
push:
branches:
- master

env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- push
- pull_request

jobs:
trial:
name: Publish Image
# Trigger workflow only for kubeflow/katib repository.
if: github.repository == 'kubeflow/katib'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Publish Trial ${{ matrix.trial-name }}
uses: ./.github/workflows/template-publish-image
with:
image: docker.io/kubeflowkatib/${{ matrix.trial-name }}
dockerfile: ${{ matrix.dockerfile }}
uses: ./.github/workflows/build-and-publish-images.yaml
with:
component-name: ${{ matrix.trial-name }}
dockerfile: ${{ matrix.dockerfile }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

strategy:
fail-fast: false
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/template-publish-image/action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Template run for publishing Katib images.
# Composite action for publishing Katib images.

inputs:
image:
Expand All @@ -7,19 +7,19 @@ inputs:
dockerfile:
required: true
type: string
push:
required: true
type: boolean

runs:
using: composite
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker Login
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}

- name: Add Docker Tags
id: meta
uses: docker/metadata-action@v3
Expand All @@ -34,8 +34,8 @@ runs:
with:
context: .
file: ${{ inputs.dockerfile }}
push: true
push: ${{ inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
platforms: linux/amd64,linux/arm64

0 comments on commit caa7b8b

Please sign in to comment.