-
Notifications
You must be signed in to change notification settings - Fork 2
136 lines (119 loc) · 4.94 KB
/
dev-build.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
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
# Copyright 2022 Greptime Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Dev Build
on:
workflow_dispatch: # Allows you to run this workflow manually.
inputs:
repository:
description: The public repository to build
required: false
default: GreptimeTeam/greptimedb-operator
commit: # Note: We only pull the source code and use the current workflow to build the artifacts.
description: The commit to build, default to the latest commit in the current branch.
required: false
build-arm64: # only build amd64 image by default, it will make the build faster.
type: boolean
description: Whether to build arm64 image
required: false
default: false
build-initializer:
type: boolean
description: Whether to build initializer image
required: false
default: false
env:
GO_VERSION: "1.23"
# The source code will check out in the following path: '${WORKING_DIR}/dev/greptimedb-operator'.
CHECKOUT_SOURCE_PATH: dev/greptimedb-operator
COMMIT: ${{ inputs.commit || github.sha }}
jobs:
docker:
name: build-images
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout greptimedb-operator
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ env.COMMIT }}
path: ${{ env.CHECKOUT_SOURCE_PATH }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.ECR_REGION }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Login to AliCloud Container Registry
uses: docker/login-action@v3
with:
registry: greptime-registry.cn-hangzhou.cr.aliyuncs.com
username: ${{ secrets.ALICLOUD_USERNAME }}
password: ${{ secrets.ALICLOUD_PASSWORD }}
- name: Configure tag
shell: bash
run: |
VERSION="dev-$(date "+%Y%m%d-%s")-$(echo "${{ env.COMMIT }}" | cut -c1-8)"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Determine the platforms to build
shell: bash
run: |
PLATFORMS="linux/amd64"
if ${{ inputs.build-arm64 }}; then
PLATFORMS="linux/amd64,linux/arm64"
fi
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
- name: Build and push operator
uses: docker/build-push-action@v5
with:
context: ${{ env.CHECKOUT_SOURCE_PATH }}
file: ./docker/operator/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: |
greptime/greptimedb-operator-dev:latest
greptime/greptimedb-operator-dev:${{ env.VERSION }}
greptime-registry.cn-hangzhou.cr.aliyuncs.com/greptime/greptimedb-operator-dev:latest
greptime-registry.cn-hangzhou.cr.aliyuncs.com/greptime/greptimedb-operator-dev:${{ env.VERSION }}
${{ vars.ECR_REGISTRY }}/greptime/greptimedb-operator-dev:latest
${{ vars.ECR_REGISTRY }}/greptime/greptimedb-operator-dev:${{ env.VERSION }}
- name: Build and push initializer
if: ${{ inputs.build-initializer }}
uses: docker/build-push-action@v5
with:
context: ${{ env.CHECKOUT_SOURCE_PATH }}
file: ./docker/initializer/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: |
greptime/greptimedb-initializer-dev:latest
greptime/greptimedb-initializer-dev:${{ env.VERSION }}
greptime-registry.cn-hangzhou.cr.aliyuncs.com/greptime/greptimedb-initializer-dev:latest
greptime-registry.cn-hangzhou.cr.aliyuncs.com/greptime/greptimedb-initializer-dev:${{ env.VERSION }}
${{ vars.ECR_REGISTRY }}/greptime/greptimedb-initializer-dev:latest
${{ vars.ECR_REGISTRY }}/greptime/greptimedb-initializer-dev:${{ env.VERSION }}