fix bug #36
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
name: Build | |
on: | |
workflow_dispatch: | |
push: | |
tags: ["v*.*.*"] | |
branches: | |
- main | |
- dev | |
jobs: | |
docker_build: | |
name: Docker Build (Multi-arch) | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
# 检查代码 | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# 登录 Docker Hub | |
- name: Log In to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASS }} | |
# 设置 Docker Buildx | |
- name: Set Up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: "v0.10.2" | |
driver: "docker-container" | |
buildkitd-flags: "--allow-insecure-entitlement security.insecure" | |
# 设置 QEMU(用于多架构支持) | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
# 提取 Docker 元数据 | |
- name: Extract Metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
docker.io/${{ secrets.DOCKER_USER }}/mail-server | |
tags: | | |
type=ref,event=tag | |
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
# 构建并推送 Docker 镜像 | |
- name: Build and Push Docker Images | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |