mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
69 lines
1.8 KiB
YAML
69 lines
1.8 KiB
YAML
name: Manual Docker Build
|
|
|
|
# 核心配置:仅允许手动触发
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
reason:
|
|
description: '构建原因'
|
|
required: false
|
|
default: 'Manual build update'
|
|
|
|
env:
|
|
IMAGE_NAME: foxhui/webai-2api
|
|
|
|
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 |