Skip to content

Xorbits CD for DockerHub #367

Xorbits CD for DockerHub

Xorbits CD for DockerHub #367

Workflow file for this run

name: Xorbits CD for DockerHub
on:
schedule:
- cron: '0 18 * * *'
push:
tags:
- '*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
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 == 'xprobe-inc/xorbits' }}
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")
else
export GIT_BRANCH=$(echo "$GITHUB_REF" | sed -e "s/refs\/heads\///g")
fi
if [[ -n "$GIT_TAG" ]]; then
BRANCHES="$GIT_TAG"
echo "Will handle tag $BRANCHES"
else
MAINBRANCH=$(git rev-parse --abbrev-ref HEAD)
BRANCHES=$(git branch -r --list 'origin/v*' | sed 's/ *origin\///g')
BRANCHES="$MAINBRANCH $BRANCHES"
echo "Will handle branches:"
for branch in $BRANCHES; do
echo " $branch"
done
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 "xprobe/xorbits:base-py$PY_VERSION" --progress=plain -f python/xorbits/deploy/docker/Dockerfile.base . --build-arg PYTHON_VERSION=$PY_VERSION
docker build -t "$DOCKER_ORG/xorbits:${IMAGE_TAG}-py${PY_VERSION}" --progress=plain -f python/xorbits/deploy/docker/Dockerfile . --build-arg PYTHON_VERSION=$PY_VERSION
docker push "xprobe/xorbits:base-py$PY_VERSION"
docker push "$DOCKER_ORG/xorbits:${IMAGE_TAG}-py${PY_VERSION}"
done
- name: Set default image
shell: bash
if: matrix.python-version == '3.10'
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")
docker tag "$DOCKER_ORG/xorbits:${GIT_TAG}-py${PY_VERSION}" "$DOCKER_ORG/xorbits:${GIT_TAG}"
docker push "$DOCKER_ORG/xorbits:${GIT_TAG}"
fi