Skip to content

Xinference CD for DockerHub #409

Xinference CD for DockerHub

Xinference CD for DockerHub #409

Workflow file for this run

name: Xinference CD for DockerHub
on:
schedule:
- cron: '0 18 * * *'
push:
tags:
- '*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
timeout-minutes: 120
runs-on: self-hosted
strategy:
matrix:
python-version: [ "3.9" ]
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image
shell: bash
if: ${{ github.repository == 'xorbitsai/inference' }}
env:
DOCKER_ORG: ${{ secrets.DOCKERHUB_USERNAME }}
PY_VERSION: ${{ matrix.python-version }}
run: |
if [[ "$GITHUB_REF" =~ ^"refs/tags/" ]]; then
export GIT_TAG=$(echo "$GITHUB_REF" | sed -e "s/refs\/tags\///g")
fi
if [[ -n "$GIT_TAG" ]]; then
BRANCHES="$GIT_TAG"
echo "Will handle tag $BRANCHES"
else
MAINBRANCH=$(git rev-parse --abbrev-ref HEAD)
BRANCHES="$MAINBRANCH"
fi
for branch in $BRANCHES; do
if [[ -n "$GIT_TAG" ]]; then
export IMAGE_TAG="$GIT_TAG"
else
git checkout $branch
export IMAGE_TAG="nightly-$branch"
fi
docker build -t "$DOCKER_ORG/xinference:${IMAGE_TAG}" --progress=plain -f xinference/deploy/docker/Dockerfile .
docker push "$DOCKER_ORG/xinference:${IMAGE_TAG}"
docker build -t "$DOCKER_ORG/xinference:${IMAGE_TAG}-cpu" --progress=plain -f xinference/deploy/docker/cpu.Dockerfile .
docker push "$DOCKER_ORG/xinference:${IMAGE_TAG}-cpu"
echo "XINFERENCE_IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
done
if [[ -n "$GIT_TAG" ]]; then
docker tag "$DOCKER_ORG/xinference:${GIT_TAG}" "$DOCKER_ORG/xinference:latest"
docker push "$DOCKER_ORG/xinference:latest"
docker tag "$DOCKER_ORG/xinference:${GIT_TAG}-cpu" "$DOCKER_ORG/xinference:latest-cpu"
docker push "$DOCKER_ORG/xinference:latest-cpu"
echo "XINFERENCE_GIT_TAG=${GIT_TAG}" >> $GITHUB_ENV
fi
- name: Clean docker image cache
shell: bash
if: ${{ github.repository == 'xorbitsai/inference' }}
run: |
docker system prune -f -a