-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 2.06 KB
/
docker.yaml
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
name: Docker
on:
push:
branches:
- main
tags:
- 'v*'
env:
APP_NAME: ${{ github.event.repository.name }}
NAMESPACE: app
REGISTRY: ${{ secrets.DOCKER_REGISTRY && secrets.DOCKER_REGISTRY || 'docker.io' }}
REPOSITORY: ${{ github.repository }}
# 判断是否是tag,是的话就使用tag作为版本号,否则使用branch
IMAGE_TAG: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || '' }}
IMAGE_LATEST_TAG: ${{ startsWith(github.ref, 'refs/tags/') && 'latest' || 'main' }}
jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [linux, darwin]
goarch: ["386", amd64, arm, arm64]
exclude:
- goos: darwin
goarch: arm
- goos: darwin
goarch: "386"
fail-fast: true
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Mkdir
run: |
mkdir -p ./frontend/dist
echo "" > ./frontend/dist/index.html
- name: Lint
uses: golangci/golangci-lint-action@v6
- name: Tests
run: |
go test $(go list ./...)
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set outputs
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Docker build and push
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
# 如果IMAGE_TAG为空,则使用${{ steps.vars.outputs.sha_short }}
tags: codfrm/dns-kit:${{ env.IMAGE_LATEST_TAG }},codfrm/dns-kit:${{ env.IMAGE_TAG && env.IMAGE_TAG || steps.vars.outputs.sha_short }}
context: .