build and push image to docker hub in a single action

Signed-off-by: Vincent Cui <dustise@live.com>
This commit is contained in:
Vincent Cui 2022-03-16 17:06:15 +08:00 committed by RainbowMango
parent 065400875c
commit 1c2dfa48ab
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,41 @@
name: Build Images and push them to Dockerhub
on:
release:
types:
- published
jobs:
release-image:
name: Release images
strategy:
matrix:
target:
- karmada-aggregated-apiserver
- karmada-controller-manager
- karmada-scheduler
- karmada-webhook
- karmada-agent
- karmada-scheduler-estimator
- karmada-interpreter-webhook-example
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
env:
VERSION: ${{ github.ref_name }}
run: make mp-image-${{ matrix.target }}

View File

@ -0,0 +1,10 @@
FROM golang:1.17 as builder
COPY karmada /code/karmada
WORKDIR /code/karmada
RUN make _TARGET_
FROM alpine:3.7
RUN apk add -u --no-cache ca-certificates
COPY --from=builder "/code/karmada/_TARGET_" /bin/
CMD ["/bin/_TARGET_"]