mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2026-07-28 03:36:10 +08:00
81 lines
2.0 KiB
YAML
81 lines
2.0 KiB
YAML
name: docker
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
paths:
|
|
- "**/*.py"
|
|
- "pyproject.toml"
|
|
- "docker/**"
|
|
- ".github/workflows/*.yml"
|
|
pull_request:
|
|
branches:
|
|
- "main"
|
|
paths:
|
|
- "**/*.py"
|
|
- "pyproject.toml"
|
|
- "docker/**"
|
|
- ".github/workflows/*.yml"
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- device: "cuda"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.device }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
environment:
|
|
name: docker
|
|
url: https://hub.docker.com/r/hiyouga/llamafactory
|
|
|
|
steps:
|
|
- name: Free up disk space
|
|
uses: jlumbroso/free-disk-space@v1.3.1
|
|
with:
|
|
tool-cache: true
|
|
docker-images: false
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Get llamafactory version
|
|
id: version
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "release" ]; then
|
|
echo "tag=$(grep -oP 'VERSION = "\K[^"]+' src/llamafactory/extras/env.py)" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "tag=latest" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker image (CUDA)
|
|
if: ${{ matrix.device == 'cuda' }}
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./docker/docker-cuda/Dockerfile
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
docker.io/hiyouga/llamafactory:${{ steps.version.outputs.tag }}
|