Skip to content

Commit 6b6ef69

Browse files
committed
chore(CI):support docker build in GitHub Actions
#704 Signed-off-by: Bo-Yi.Wu <[email protected]>
1 parent 7101fbd commit 6b6ef69

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

.github/workflows/build.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- master
7+
tags:
8+
- 'v*'
79

810
jobs:
911
build:
@@ -27,3 +29,110 @@ jobs:
2729
- name: Check binary
2830
run : |
2931
./release/linux/amd64/gorush --help
32+
33+
-
34+
name: Set up QEMU
35+
uses: docker/setup-qemu-action@v2
36+
-
37+
name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v2
39+
40+
-
41+
name: Login to Docker Hub
42+
uses: docker/login-action@v2
43+
with:
44+
username: ${{ secrets.DOCKERHUB_USERNAME }}
45+
password: ${{ secrets.DOCKERHUB_TOKEN }}
46+
47+
-
48+
name: Login to GitHub Container Registry
49+
uses: docker/login-action@v2
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.repository_owner }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
-
56+
name: Docker meta for linux amd64
57+
id: meta-linux-amd64
58+
uses: docker/metadata-action@v4
59+
with:
60+
flavor: |
61+
latest=false
62+
suffix=linux-amd64
63+
images: |
64+
appleboy/gorush
65+
ghcr.io/appleboy/gorush
66+
tags: |
67+
type=raw,value=
68+
type=raw,value=latest,suffix=,enable={{is_default_branch}}
69+
type=semver,event=tag,pattern={{version}},suffix=-linux-amd64
70+
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-amd64
71+
type=semver,event=tag,pattern={{major}},suffix=-linux-amd64
72+
73+
-
74+
name: Build and push linux amd64
75+
uses: docker/build-push-action@v3
76+
with:
77+
context: .
78+
file: docker/Dockerfile.linux.amd64
79+
platforms: linux/amd64
80+
push: true
81+
tags: ${{ steps.meta-linux-amd64.outputs.tags }}
82+
labels: ${{ steps.meta-linux-amd64.outputs.labels }}
83+
84+
-
85+
name: Docker meta for linux arm64
86+
id: meta-linux-arm64
87+
uses: docker/metadata-action@v4
88+
with:
89+
flavor: |
90+
latest=false
91+
suffix=linux-arm64
92+
images: |
93+
appleboy/gorush
94+
ghcr.io/appleboy/gorush
95+
tags: |
96+
type=raw,value=
97+
type=semver,event=tag,pattern={{version}},suffix=-linux-arm64
98+
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm64
99+
type=semver,event=tag,pattern={{major}},suffix=-linux-arm64
100+
101+
-
102+
name: Build and push linux arm64
103+
uses: docker/build-push-action@v3
104+
with:
105+
context: .
106+
file: docker/Dockerfile.linux.arm64
107+
platforms: linux/arm64
108+
push: true
109+
tags: ${{ steps.meta-linux-arm64.outputs.tags }}
110+
labels: ${{ steps.meta-linux-arm64.outputs.labels }}
111+
112+
-
113+
name: Docker meta for linux arm
114+
id: meta-linux-arm
115+
uses: docker/metadata-action@v4
116+
with:
117+
flavor: |
118+
latest=false
119+
suffix=linux-arm
120+
images: |
121+
appleboy/gorush
122+
ghcr.io/appleboy/gorush
123+
tags: |
124+
type=raw,value=
125+
type=semver,event=tag,pattern={{version}},suffix=-linux-arm
126+
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm
127+
type=semver,event=tag,pattern={{major}},suffix=-linux-arm
128+
129+
-
130+
name: Build and push linux arm
131+
uses: docker/build-push-action@v3
132+
with:
133+
context: .
134+
file: docker/Dockerfile.linux.arm
135+
platforms: linux/arm
136+
push: true
137+
tags: ${{ steps.meta-linux-arm.outputs.tags }}
138+
labels: ${{ steps.meta-linux-arm.outputs.labels }}

0 commit comments

Comments
 (0)