adding matrix-cache #8
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
name: Sklearn Server Docker Publisher | |
on: | |
push: | |
# Publish `master` as Docker `latest` image. | |
branches: | |
- master | |
- sklearn-runtime-matrix-cache | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
# Run tests for any PRs. | |
pull_request: | |
env: | |
IMAGE_NAME: sklearnserver | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# Run tests. | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
platform: [linux/amd64, linux/arm64/v8, linux/ppc64le] | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Cache Docker layers using GitHub Actions caching | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-docker-${{ matrix.platform }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-docker-${{ matrix.platform }}- | |
- name: Run tests | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: ${{ matrix.platform }} | |
context: python | |
file: python/sklearn.Dockerfile | |
push: false | |
# Use the cache for Docker layers | |
cache-from: type=gha,mode=max # Utilize GitHub Actions cache | |
cache-to: type=gha,mode=max | |
# Disable provenance (optional) | |
provenance: false | |
# Push image to GitHub Packages. | |
push: | |
# Ensure the test job passes before pushing the image. | |
needs: test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
platform: [linux/amd64, linux/arm64/v8, linux/ppc64le] | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Export version variable | |
run: | | |
IMAGE_ID=kserve/$IMAGE_NAME | |
# Convert to lowercase and strip prefixes | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
[ "$VERSION" == "master" ] && VERSION=latest | |
echo VERSION=$VERSION >> $GITHUB_ENV | |
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: ${{ matrix.platform }} | |
context: python | |
file: python/sklearn.Dockerfile | |
push: true | |
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }} | |
cache-from: type=gha,mode=max # Utilize GitHub Actions cache | |
cache-to: type=gha,mode=max | |
# Disable provenance (optional) | |
provenance: false | |