Skip to content

Commit

Permalink
feat: push images to dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlihanbo committed Jun 5, 2024
1 parent 79c6330 commit 2ead9c8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/dockerhub-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and push latest images to DockerHub

on:
push:
branches: ["main", "ci-test"]

permissions:
packages: write

jobs:
publish-images-to-dockerhub:
name: Publish to DockerHub
if: ${{ github.repository == 'kubewharf/kubeadmiral' }}
runs-on: [ubuntu-latest]
steps:
- name: checkout code
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and publish images
env:
REGISTRY: kubewharf
TAG: latest
OUTPUT_TYPE: registry
run: make images
31 changes: 31 additions & 0 deletions .github/workflows/dokcerhub-released.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and push released images to DockerHub

on:
release:
types:
- published

permissions:
packages: write

jobs:
publish-images-to-dockerhub:
name: Publish to DockerHub
if: ${{ github.repository == 'kubewharf/kubeadmiral' }}
runs-on: [ubuntu-latest]
steps:
- name: checkout code
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and publish images
env:
REGISTRY: kubewharf
TAG: ${{ github.ref_name }}
OUTPUT_TYPE: registry
run: make images
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ DEBUG_TARGET_NAME ?= $(TARGET_NAME)_debug
REGISTRY ?= ghcr.io/kubewharf
TAG ?= latest
REGION ?=
OUTPUT_TYPE ?=

ifeq (${REGION}, cn)
GOPROXY := https://goproxy.cn,direct
Expand Down Expand Up @@ -123,7 +124,7 @@ local-up:
images:
REGISTRY=$(REGISTRY) TAG=$(TAG) ARCHS=$(ARCHS) GOPROXY=$(GOPROXY) REGION=$(REGION) \
DOCKER_BUILD_ARGS="$(DOCKER_BUILD_ARGS)" DOCKERFILE_PATH="$(DOCKERFILE_PATH)" \
TARGET_NAME="$(TARGET_NAME)" bash hack/make-rules/build-images.sh
TARGET_NAME="$(TARGET_NAME)" OUTPUT_TYPE="$(OUTPUT_TYPE)" bash hack/make-rules/build-images.sh

# Clean built binaries
.PHONY: clean
Expand Down
4 changes: 4 additions & 0 deletions hack/lib/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,8 @@ function build::build_images() {
--tag ${image_name} \
--file ${dockerfile_path} \
${REPO_ROOT}

if [[ "$output_type" == "registry" ]]; then
docker push "${image_name}"
fi
}

0 comments on commit 2ead9c8

Please sign in to comment.