-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (37 loc) · 1.2 KB
/
build-and-push.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
name: Build and Push Docker Image
on:
push:
tags:
- "v*.*.*"
- "v*.*.*-beta.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout backend repository
uses: actions/checkout@v2
- name: Get current tag
id: get_tag
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "stable" # 使用你需要的 Go 版本
- name: Build
run: |
go build -o clashmerge .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
run: |
TAG=${GITHUB_REF#refs/tags/}
if [[ "$TAG" == *-beta.* ]]; then
docker buildx build --platform linux/amd64,linux/arm64 -t mailth/clashmerge:$TAG --push .
else
docker buildx build --platform linux/amd64,linux/arm64 -t mailth/clashmerge:$TAG -t mailth/clashmerge:latest --push .
fi