mirror of
https://github.com/Moe-Sakura/Wrangler-API.git
synced 2026-03-15 04:13:18 +08:00
57 lines
1.4 KiB
YAML
57 lines
1.4 KiB
YAML
name: 构建并推送 Docker 镜像
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
REGISTRY: docker.io
|
|
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/SearchGal-Api
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: 构建与推送
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: 检出源代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 设置 QEMU (用于支持多架构构建)
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: 设置 Docker Buildx (增强版构建工具)
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: 登录到 Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: 提取镜像元数据 (生成 Tag 和 Label)
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
- name: 执行构建并推送镜像
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|