Build & Publush #109
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
# This is a basic workflow to help you get started with Actions | |
name: Build & Publush | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on all push or pull request events | |
push: | |
pull_request: | |
release: | |
types: [created] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
# added using https://github.com/step-security/secure-repo | |
permissions: | |
contents: read | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
Docker: | |
name: Build&Push to DockerHub | |
if: (github.event_name == 'push' || github.event_name == 'pull_request') | |
runs-on: [self-hosted, linux, x64] | |
strategy: | |
matrix: | |
infer-hw: ['nvidia', 'intel'] | |
env: | |
DOCKER_REPO: 'sippylabs/infernos' | |
BASE_IMAGE: 'ubuntu:24.10' | |
PYTHON_VER: '3.11' | |
CONDA_MAINENV: 'Infernos' | |
INFER_HW: ${{ matrix.infer-hw }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_REPO }} | |
tags: | | |
type=schedule | |
type=ref,event=branch,prefix=${{ env.INFER_HW }}- | |
type=ref,event=tag,prefix=${{ env.INFER_HW }}- | |
type=ref,event=pr,prefix=${{ env.INFER_HW }}- | |
type=raw,value=${{ env.INFER_HW }}-latest,enable={{is_default_branch}} | |
type=sha | |
- name: Get branch name | |
run: echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV | |
- name: Build Docker image | |
uses: docker/build-push-action@v6 | |
env: | |
CACHE_SPEC: "type=registry,ref=${{ env.DOCKER_REPO }}:${{ env.INFER_HW }}-${{ env.GIT_BRANCH }}-buildcache" | |
with: | |
context: . | |
file: ./docker/Dockerfile | |
push: true | |
build-args: | | |
BASE_IMAGE=${{ env.BASE_IMAGE }} | |
PYTHON_VER=${{ env.PYTHON_VER }} | |
CONDA_MAINENV=${{ env.CONDA_MAINENV }} | |
INFER_HW=${{ env.INFER_HW }} | |
tags: | | |
${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: ${{ env.CACHE_SPEC }} | |
cache-to: ${{ env.CACHE_SPEC }},mode=max | |
#cache-from: type=gha | |
#cache-to: type=registry,ref=${{ env.DOCKER_REPO }}:${{ env.INFER_HW }}-buildcache,mode=max |