forked from stalwartlabs/mail-server
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (103 loc) · 3.32 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Credits: https://github.com/33KK
name: Build
on:
workflow_dispatch:
push:
tags: ["v*.*.*"]
branches:
- main
- dev
jobs:
build_mac_arm:
name: Build Mac ARM (Apple Silicon)
if: github.event_name == 'push'
runs-on: macos-latest
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/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
docker_build:
name: Docker Build (Linux x86)
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
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}