-
Notifications
You must be signed in to change notification settings - Fork 46
127 lines (121 loc) · 4.08 KB
/
push-image.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
name: Build Images
on:
push:
branches:
- main
- feature/*
jobs:
build-fronted:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v4
with:
version: 8.15.6
- name: Build dashboard
run: |
echo "Start build"
pnpm --version
cd ui
pnpm install -w
pnpm run dashboard:build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
path: ui/apps/dashboard/dist
name: dashboard_artifact
build-and-push-web:
runs-on: ubuntu-latest
needs: [ "build-fronted" ]
env:
IMAGE_NAME: karmada/karmada-dashboard-web
BINARY_NAME: karmada-dashboard-web
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '^1.22.2'
- name: Detect misc info
id: misc
run: |
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build karmada-dashboard-web binary
run: make bin-karmada-dashboard-web
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dashboard_artifact
path: _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
- name: Display artifact
run: |
ls -al _output/bin
ls -al _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
- name: Extract metadata for the Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.misc.outputs.image_name }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: "cluster/images/build-web.Dockerfile"
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BINARY=${{ steps.misc.outputs.binary_name }}
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}
build-and-push-api:
runs-on: ubuntu-latest
env:
IMAGE_NAME: karmada/karmada-dashboard-api
BINARY_NAME: karmada-dashboard-api
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '^1.22.2'
- name: Detect misc info
id: misc
run: |
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata for the Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.misc.outputs.image_name }}
- name: Build karmada-dashboard-api binary
run: make karmada-dashboard-api
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: "cluster/images/Dockerfile"
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BINARY=${{ steps.misc.outputs.binary_name }}
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}