Skip to content

Commit

Permalink
Adding GHA for automatic image build and push (#1615)
Browse files Browse the repository at this point in the history
* Adding latest image tag

* Update manifests with latest image tag

* Add github actions for image build/push
  • Loading branch information
johnugeorge authored Jun 15, 2022
1 parent 65ad3d5 commit 25c0872
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/publish-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Training Images

on:
push:
branches:
- master

env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

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

- name: Publish Docker Images ${{ matrix.name }}
uses: ./.github/workflows/template-publish-image
with:
image: docker.io/kubeflow/${{ matrix.name }}
dockerfile: ${{ matrix.dockerfile }}

strategy:
fail-fast: false
matrix:
include:
- name: training-operator
dockerfile: build/images/training-operator/Dockerfile
# Add example images in the future
40 changes: 40 additions & 0 deletions .github/workflows/template-publish-image/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Template run for publishing images.

inputs:
image:
required: true
type: string
dockerfile:
required: true
type: string

runs:
using: composite
steps:
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v1

- 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
with:
images: ${{ inputs.image }}
tags: |
type=raw,latest
type=sha,prefix=v1-
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
file: ${{ inputs.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 25c0872

Please sign in to comment.