mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
ci: 新增 Docker 发布工作流
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
name: Manual Docker Build
|
||||
|
||||
# 核心配置:仅允许手动触发
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
reason:
|
||||
description: '构建原因'
|
||||
required: false
|
||||
default: 'Manual build update'
|
||||
|
||||
env:
|
||||
# 请修改为你的 Docker Hub 镜像名称 (格式: 用户名/仓库名)
|
||||
IMAGE_NAME: foxhui/lmarena-imagen-automator
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
# 1. 拉取代码
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# 2. 设置 QEMU (支持多架构构建,如 ARM64)
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
# 3. 设置 Docker Buildx
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 4. 登录 Docker Hub
|
||||
- name: Log into Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# 5. 生成 Docker 标签
|
||||
# 逻辑:
|
||||
# - 总是打上 'latest' 标签
|
||||
# - 额外打上 'sha-xxxxxxx' (基于当前 commit 的哈希)
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
type=sha,format=short
|
||||
|
||||
# 6. 构建并推送
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
# 开启推送
|
||||
push: true
|
||||
# 使用上面生成的标签
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
# 缓存加速
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
# 同时构建 PC (amd64) 和 Mac/树莓派 (arm64) 版本
|
||||
platforms: linux/amd64,linux/arm64
|
||||
Reference in New Issue
Block a user