From 094e685dd6dcd9d340a1a334b0d950f60cdfbdd3 Mon Sep 17 00:00:00 2001 From: liujian <54946465+redscholar@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:49:53 +0800 Subject: [PATCH] fix: sync image to aliyuns repo Signed-off-by: joyceliu --- .github/workflows/release.yml | 63 +++++++++++++++++++++++++++------- hack/docker_build_multiarch.sh | 22 +++++------- 2 files changed, 59 insertions(+), 26 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7608a702b32..50cd6e79121 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,30 +5,67 @@ on: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 name: Build Release -env: - # TODO: Change variable to your image's name. - IMAGE_NAME: ks-console - IMAGE_REPO: kubesphere - jobs: - release-linux-amd64: + release: runs-on: ubuntu-latest if: github.repository == 'kubesphere/console' steps: - uses: actions/checkout@v2 + - name: Login to Aliyun + uses: docker/login-action@v3 + with: + registry: registry.cn-beijing.aliyuncs.com + username: ${{ secrets.ALIYUNCS_USERNAME }} + password: ${{ secrets.ALIYUNCS_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@v1 + uses: docker/setup-qemu-action@v3 with: platforms: all - name: Set up Docker buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - - name: Log into registry - run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + - 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: Push image + - name: Generate output dir run: | - TAG=${GITHUB_REF#refs/*/} REPO=$IMAGE_REPO make container-cross-push - echo "Push $IMAGE success!" + make container-cross + + - name: Build and push ks-console images + uses: docker/build-push-action@v6 + if: steps.chose_registry.outputs.env == 'prod' + with: + context: ${{ github.workspace }} + file: build/Dockerfile.dapper + platforms: linux/amd64,linux/arm64 + push: true + tags: | + docker.io/kubesphere/ks-console:${{ steps.chose_registry.outputs.tag }} + registry.cn-beijing.aliyuncs.com/kubesphereio/ks-console:${{ steps.chose_registry.outputs.tag }} + + - name: Build and push ks-console dev images + uses: docker/build-push-action@v6 + if: steps.chose_registry.outputs.env == 'dev' + with: + context: ${{ github.workspace }} + file: build/Dockerfile.dapper + platforms: linux/amd64,linux/arm64 + push: true + tags: | + docker.io/kubespheredev/ks-console:${{ steps.chose_registry.outputs.tag }} diff --git a/hack/docker_build_multiarch.sh b/hack/docker_build_multiarch.sh index 4e9e94b5660..c0d3cdc7350 100755 --- a/hack/docker_build_multiarch.sh +++ b/hack/docker_build_multiarch.sh @@ -5,17 +5,12 @@ set -o pipefail TAG=${TAG:-latest} REPO=${REPO:-kubespheredev} -PUSH=${PUSH:-} +DRY_RUN=${DRY_RUN:-false} # support other container tools. e.g. podman CONTAINER_CLI=${CONTAINER_CLI:-docker} CONTAINER_BUILDER=${CONTAINER_BUILDER:-"buildx build"} -# If set, just building, no pushing -if [[ -z "${DRY_RUN:-}" ]]; then - PUSH="--push" -fi - ## supported platforms PLATFORMS=linux/amd64,linux/arm64 @@ -39,10 +34,11 @@ mv "$PROJECT_DIR"/server/locales \ "$PROJECT_DIR"/server/sample \ "$PROJECT_DIR"/server/configs "$PROJECT_DIR"/out/server/ -# shellcheck disable=SC2086 # inteneded splitting of CONTAINER_BUILDER -${CONTAINER_CLI} ${CONTAINER_BUILDER} \ - --platform ${PLATFORMS} \ - ${PUSH} \ - -f build/Dockerfile.dapper \ - -t "${REPO}"/ks-console:"${TAG}" . - +if [ "$DRY_RUN" = "false" ]; then + # shellcheck disable=SC2086 # inteneded splitting of CONTAINER_BUILDER + ${CONTAINER_CLI} ${CONTAINER_BUILDER} \ + --platform ${PLATFORMS} \ + --push \ + -f build/Dockerfile.dapper \ + -t "${REPO}"/ks-console:"${TAG}" . +fi