forked from kubesphere/kubesphere
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (97 loc) · 4.08 KB
/
build-multiarch.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
name: BuildContainerImage
on:
push:
branches:
- 'master'
- 'release-*'
tags:
- 'v*'
workflow_dispatch: # Manual trigger
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to HUAWEICLOUD
uses: docker/login-action@v3
with:
registry: swr.cn-southwest-2.myhuaweicloud.com
username: ${{ secrets.HUAWEICLOUD_USERNAME }}
password: ${{ secrets.HUAWEICLOUD_PASSWORD }}
- name: Login to DOCKER
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Chose Registry by tag
id: chose_registry
run: |
if [[ ${GITHUB_REF#refs/*/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "env=prod" >> "$GITHUB_OUTPUT"
else
echo "env=dev" >> "$GITHUB_OUTPUT"
fi
echo "tag=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT"
- name: Build and push ks-apiserver images
uses: docker/build-push-action@v6
if: steps.chose_registry.outputs.env == 'prod'
with:
context: ${{ github.workspace }}
file: build/ks-apiserver/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
docker.io/kubesphere/ks-apiserver:${{ steps.chose_registry.outputs.tag }}
- name: Build and push ks-apiserver dev images
uses: docker/build-push-action@v6
if: steps.chose_registry.outputs.env == 'dev'
with:
context: ${{ github.workspace }}
file: build/ks-apiserver/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
docker.io/kubespheredev/ks-apiserver:${{ steps.chose_registry.outputs.tag }}
- name: Build and push ks-controller-manager images
uses: docker/build-push-action@v6
if: steps.chose_registry.outputs.env == 'prod'
with:
context: ${{ github.workspace }}
file: build/ks-controller-manager/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
docker.io/kubesphere/ks-controller-manager:${{ steps.chose_registry.outputs.tag }}
- name: Build and push ks-controller-manager dev images
uses: docker/build-push-action@v6
if: steps.chose_registry.outputs.env == 'dev'
with:
context: ${{ github.workspace }}
file: build/ks-controller-manager/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
docker.io/kubespheredev/ks-controller-manager:${{ steps.chose_registry.outputs.tag }}
- name: Sync ks images to HUAWEICLOUD
if: steps.chose_registry.outputs.env == 'prod'
run: |
# apiserver
docker pull docker.io/kubesphere/ks-apiserver:${{ steps.chose_registry.outputs.tag }}
docker tag docker.io/kubesphere/ks-apiserver:${{ steps.chose_registry.outputs.tag }} swr.cn-southwest-2.myhuaweicloud.com/ks/kubesphere/ks-apiserver:${{ steps.chose_registry.outputs.tag }}
docker push swr.cn-southwest-2.myhuaweicloud.com/ks/kubesphere/ks-apiserver:${{ steps.chose_registry.outputs.tag }}
# controller-manager
docker pull docker.io/kubesphere/ks-controller-manager:${{ steps.chose_registry.outputs.tag }}
docker tag docker.io/kubesphere/ks-controller-manager:${{ steps.chose_registry.outputs.tag }} swr.cn-southwest-2.myhuaweicloud.com/ks/kubesphere/ks-controller-manager:${{ steps.chose_registry.outputs.tag }}
docker push swr.cn-southwest-2.myhuaweicloud.com/ks/kubesphere/ks-controller-manager:${{ steps.chose_registry.outputs.tag }}