Skip to content

Commit 3939721

Browse files
authored
Merge pull request #202 from warjiang/feat/image-workflow
add ci for latest/released image
2 parents e682696 + b941d74 commit 3939721

File tree

2 files changed

+252
-0
lines changed

2 files changed

+252
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Push latest image to DockerHub
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build-fronted:
13+
name: build frontend bundle
14+
if: ${{ github.repository == 'karmada-io/dashboard' }}
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: checkout code
18+
uses: actions/checkout@v4
19+
- name: setup node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
- name: install node dependencies
24+
uses: pnpm/action-setup@v4
25+
with:
26+
version: 8.15.6
27+
- name: build dashboard
28+
run: |
29+
echo "Start build"
30+
pnpm --version
31+
cd ui
32+
pnpm install -w
33+
pnpm run dashboard:build
34+
- name: upload artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
path: ui/apps/dashboard/dist
38+
name: dashboard_artifact
39+
40+
build-and-push-web:
41+
name: build and push web image
42+
if: ${{ github.repository == 'karmada-io/dashboard' }}
43+
runs-on: ubuntu-22.04
44+
needs: [ "build-fronted" ]
45+
env:
46+
IMAGE_NAME: karmada/karmada-dashboard-web
47+
BINARY_NAME: karmada-dashboard-web
48+
steps:
49+
- name: checkout code
50+
uses: actions/checkout@v4
51+
- name: install Go
52+
uses: actions/setup-go@v5
53+
with:
54+
go-version-file: go.mod
55+
- name: detect misc info
56+
id: misc
57+
run: |
58+
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
59+
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
60+
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
61+
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
62+
- name: login to DockerHub
63+
uses: docker/login-action@v3
64+
with:
65+
username: ${{ secrets.DOCKERHUB_USER_NAME }}
66+
password: ${{ secrets.DOCKERHUB_TOKEN }}
67+
- name: build karmada-dashboard-web binary
68+
run: make karmada-dashboard-web
69+
- name: download artifact
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: dashboard_artifact
73+
path: _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
74+
- name: display artifact
75+
run: |
76+
ls -al _output/bin
77+
ls -al _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
78+
- name: build and push image
79+
uses: docker/build-push-action@v6
80+
with:
81+
file: "cluster/images/build-web.Dockerfile"
82+
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
83+
push: true
84+
tags: ${{ steps.misc.outputs.image_name }}:latest
85+
build-args: |
86+
BINARY=${{ steps.misc.outputs.binary_name }}
87+
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}
88+
89+
build-and-push-api:
90+
name: build and push api image
91+
if: ${{ github.repository == 'karmada-io/dashboard' }}
92+
runs-on: ubuntu-22.04
93+
env:
94+
IMAGE_NAME: karmada/karmada-dashboard-api
95+
BINARY_NAME: karmada-dashboard-api
96+
steps:
97+
- name: checkout code
98+
uses: actions/checkout@v4
99+
- name: install Go
100+
uses: actions/setup-go@v5
101+
with:
102+
go-version-file: go.mod
103+
- name: detect misc info
104+
id: misc
105+
run: |
106+
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
107+
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
108+
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
109+
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
110+
- name: login to DockerHub
111+
uses: docker/login-action@v3
112+
with:
113+
username: ${{ secrets.DOCKERHUB_USER_NAME }}
114+
password: ${{ secrets.DOCKERHUB_TOKEN }}
115+
- name: build karmada-dashboard-api binary
116+
run: make karmada-dashboard-api
117+
- name: build and push image
118+
uses: docker/build-push-action@v6
119+
with:
120+
file: "cluster/images/Dockerfile"
121+
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
122+
push: true
123+
tags: ${{ steps.misc.outputs.image_name }}:latest
124+
build-args: |
125+
BINARY=${{ steps.misc.outputs.binary_name }}
126+
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Push released image to DockerHub
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build-fronted:
13+
name: build frontend bundle
14+
if: ${{ github.repository == 'karmada-io/dashboard' }}
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: checkout code
18+
uses: actions/checkout@v4
19+
- name: setup node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
- name: install node dependencies
24+
uses: pnpm/action-setup@v4
25+
with:
26+
version: 8.15.6
27+
- name: build dashboard
28+
run: |
29+
echo "Start build"
30+
pnpm --version
31+
cd ui
32+
pnpm install -w
33+
pnpm run dashboard:build
34+
- name: upload artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
path: ui/apps/dashboard/dist
38+
name: dashboard_artifact
39+
40+
build-and-push-web:
41+
name: build and push web image
42+
if: ${{ github.repository == 'karmada-io/dashboard' }}
43+
runs-on: ubuntu-22.04
44+
needs: [ "build-fronted" ]
45+
env:
46+
IMAGE_NAME: karmada/karmada-dashboard-web
47+
BINARY_NAME: karmada-dashboard-web
48+
steps:
49+
- name: checkout code
50+
uses: actions/checkout@v4
51+
- name: install Go
52+
uses: actions/setup-go@v5
53+
with:
54+
go-version-file: go.mod
55+
- name: detect misc info
56+
id: misc
57+
run: |
58+
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
59+
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
60+
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
61+
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
62+
- name: login to DockerHub
63+
uses: docker/login-action@v3
64+
with:
65+
username: ${{ secrets.DOCKERHUB_USER_NAME }}
66+
password: ${{ secrets.DOCKERHUB_TOKEN }}
67+
- name: build karmada-dashboard-web binary
68+
run: make karmada-dashboard-web
69+
- name: download artifact
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: dashboard_artifact
73+
path: _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
74+
- name: display artifact
75+
run: |
76+
ls -al _output/bin
77+
ls -al _output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}/dist
78+
- name: build and push image
79+
uses: docker/build-push-action@v6
80+
with:
81+
file: "cluster/images/build-web.Dockerfile"
82+
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
83+
push: true
84+
tags: ${{ steps.misc.outputs.image_name }}:${{ github.ref_name }}
85+
build-args: |
86+
BINARY=${{ steps.misc.outputs.binary_name }}
87+
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}
88+
89+
build-and-push-api:
90+
name: build and push api image
91+
if: ${{ github.repository == 'karmada-io/dashboard' }}
92+
runs-on: ubuntu-22.04
93+
env:
94+
IMAGE_NAME: karmada/karmada-dashboard-api
95+
BINARY_NAME: karmada-dashboard-api
96+
steps:
97+
- name: checkout code
98+
uses: actions/checkout@v4
99+
- name: install Go
100+
uses: actions/setup-go@v5
101+
with:
102+
go-version-file: go.mod
103+
- name: detect misc info
104+
id: misc
105+
run: |
106+
echo "os=$(go env GOHOSTOS)" >> $GITHUB_OUTPUT
107+
echo "arch=$(go env GOHOSTARCH)" >> $GITHUB_OUTPUT
108+
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
109+
echo "binary_name=$BINARY_NAME" >> $GITHUB_OUTPUT
110+
- name: login to DockerHub
111+
uses: docker/login-action@v3
112+
with:
113+
username: ${{ secrets.DOCKERHUB_USER_NAME }}
114+
password: ${{ secrets.DOCKERHUB_TOKEN }}
115+
- name: build karmada-dashboard-api binary
116+
run: make karmada-dashboard-api
117+
- name: build and push image
118+
uses: docker/build-push-action@v6
119+
with:
120+
file: "cluster/images/Dockerfile"
121+
context: "_output/bin/${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}"
122+
push: true
123+
tags: ${{ steps.misc.outputs.image_name }}:${{ github.ref_name }}
124+
build-args: |
125+
BINARY=${{ steps.misc.outputs.binary_name }}
126+
BUILD_PLATFORMS=${{ steps.misc.outputs.os }}/${{ steps.misc.outputs.arch }}

0 commit comments

Comments
 (0)