-
Notifications
You must be signed in to change notification settings - Fork 336
137 lines (120 loc) · 4.64 KB
/
server-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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: build server
on:
push:
branches:
- main
- v6.[1-9]
- v7.[1-9]
- 'feature-**'
paths:
- 'server/**'
- 'message/**'
tags:
- '*'
workflow_dispatch:
inputs:
ref:
description: "Why trigger?"
required: true
type: string
env:
IMAGE: "deepflow-server"
jobs:
build_server:
name: build server
runs-on: "cirun-aws-amd64-32c--${{ github.run_id }}"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.21.x
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.6.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
# sudo apt-get update
# sudo apt-get -y install tmpl python3 python3-pip
pip3 install ujson
GO111MODULE="off" go get github.com/gogo/protobuf/protoc-gen-gofast
GO111MODULE="off" go get github.com/gogo/protobuf/proto
GO111MODULE="off" go get github.com/gogo/protobuf/jsonpb
GO111MODULE="off" go get github.com/gogo/protobuf/protoc-gen-gogo
GO111MODULE="off" go get github.com/gogo/protobuf/gogoproto
GO111MODULE="off" go get github.com/golang/protobuf/protoc-gen-go
# - name: install docker
# run: |
# sudo systemctl stop unattended-upgrades
# curl -fsSL https://get.docker.com | bash
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: "ghcr.io"
username: "${{ github.repository_owner }}"
password: "${{ secrets.GHCR_PUSH_TOKEN }}"
- name: Log in to Docker Registry
uses: docker/login-action@v2
with:
username: "deepflowce"
password: "${{ secrets.REGISTRY_PASS }}"
- name: Log in to ALIYUN HongKong Docker Registry
uses: docker/login-action@v2
with:
registry: "registry.cn-hongkong.aliyuncs.com"
username: "${{ secrets.REGISTRY_ALIYUN_USER }}"
password: "${{ secrets.REGISTRY_PASS }}"
- name: build server
run: |
cd server
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 make -e BINARY_SUFFIX=.arm64 -e BRANCH=${{ github.ref_name }}
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make -e BINARY_SUFFIX=.amd64 -e BRANCH=${{ github.ref_name }}
- name: set env
run: |
echo "IMAGE_TAG_PREFIX=${{ github.ref_name }}"|sed 's|=main$|=latest|' >> $GITHUB_ENV
echo "IMAGE_TAG=$(git rev-list --count HEAD)" >> $GITHUB_ENV
- name: Build and push deepflow server images to ghcr and dockerhub
uses: docker/build-push-action@v2
with:
context: server
push: true
file: server/Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
"ghcr.io/${{ github.repository_owner }}/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ env.IMAGE_TAG }}"
"ghcr.io/${{ github.repository_owner }}/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
"deepflowce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
- name: Build and push deepflow server images to hongkong aliyun
uses: docker/build-push-action@v2
with:
context: server
push: true
file: server/Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
"registry.cn-hongkong.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ env.IMAGE_TAG }}"
"registry.cn-hongkong.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
- name: Log in to ALIYUN Docker Registry
uses: docker/login-action@v2
with:
registry: "registry.cn-beijing.aliyuncs.com"
username: "${{ secrets.REGISTRY_ALIYUN_USER }}"
password: "${{ secrets.REGISTRY_PASS }}"
- name: Build and push deepflow server images to beijing aliyun
uses: docker/build-push-action@v2
with:
context: server
push: true
file: server/Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
"registry.cn-beijing.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ env.IMAGE_TAG }}"
"registry.cn-beijing.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"