Skip to content

Build OneDiff

Build OneDiff #1988

Workflow file for this run

name: Build OneDiff
on:
push:
branches:
- main
- enable-docker-hub-cache
- "img/*"
schedule:
# every 6 hours
- cron: "0 */6 * * *"
workflow_dispatch:
env:
REGION_ID: cn-beijing
REGISTRY: registry.cn-beijing.aliyuncs.com
NAMESPACE: oneflow
ONEFLOW_PIP_INDEX: "https://oneflow-pro.oss-cn-beijing.aliyuncs.com/branch/community/cu118"
concurrency:
group: sd-${{ github.ref }}
cancel-in-progress: true
jobs:
build-oneflow:
name: Build sd ${{ matrix.image.repo }}:${{ matrix.image.suffix }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
image:
- {
BASE_IMAGE: "nvcr.io/nvidia/pytorch:23.08-py3",
suffix: "cu118",
repo: "onediff",
}
- {
BASE_IMAGE: "nvcr.io/nvidia/pytorch:23.08-py3",
suffix: "cu121",
repo: "onediff-pro",
}
- {
BASE_IMAGE: "nvcr.io/nvidia/pytorch:23.08-py3",
suffix: "cu122",
repo: "onediff-pro",
}
env:
DOCKER_BUILDKIT: 1
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 512
swap-size-mb: 1024
remove-dotnet: "true"
remove-android: "true"
remove-haskell: "true"
remove-codeql: "true"
remove-docker-images: "true"
overprovision-lvm: "true"
- name: Checkout
uses: actions/checkout@v2
- run: ls -al
- run: sudo apt-get install ripgrep
# 1.1 Login to ACR
- name: Login to ACR with the AccessKey pair
uses: aliyun/acr-login@v1
with:
login-server: https://registry.${{env.REGION_ID}}.aliyuncs.com
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 1.2 Build and push image to ACR
- name: Set env
run: |
echo ACR_TAG="$REGISTRY/$NAMESPACE/${{ matrix.image.repo }}:${{ matrix.image.suffix }}" >> $GITHUB_ENV
echo DOCKERHUB_TAG="oneflowinc/${{ matrix.image.repo }}:${{ matrix.image.suffix }}" >> $GITHUB_ENV
- name: Set env (Pro)
if: matrix.image.repo == 'onediff-pro'
run: |
echo ONEFLOW_PIP_INDEX="https://${{ secrets.ONEFLOW_PRIV_OSS_BUCKET }}.oss-cn-beijing.aliyuncs.com/branch/main/${{ matrix.image.suffix }}" >> $GITHUB_ENV
- name: Get OneFlow version
id: get-oneflow-version
run: |
curl "${{ env.ONEFLOW_PIP_INDEX }}"
ONEFLOW_PIP_INDEX=${{ env.ONEFLOW_PIP_INDEX }}
DEV_VERSION=$(curl ${{ env.ONEFLOW_PIP_INDEX }} | rg '/oneflow-(\d.+?)%2B(.+?)-cp' -or '$1+${2}' | head -n 1)
echo "DEV_VERSION: ${DEV_VERSION}"
if [ -z "$DEV_VERSION" ]
then
exit 1
fi
echo "ONEFLOW_PACKAGE_NAME="oneflow==${DEV_VERSION}"" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: |
${{ env.DOCKERHUB_TAG }}
${{ env.ACR_TAG }}
cache-from: type=registry,ref=${{ env.DOCKERHUB_TAG }}
cache-to: type=inline
target: ${{ matrix.build-target }}
build-args: |
BASE_IMAGE=${{matrix.image.BASE_IMAGE}}
ONEFLOW_PIP_INDEX=${{ env.ONEFLOW_PIP_INDEX }}
ONEFLOW_PACKAGE_NAME=${{steps.get-oneflow-version.outputs.ONEFLOW_PACKAGE_NAME}}
- name: Push image to ACR
run: |
docker push "${{ env.ACR_TAG }}"