diff --git a/.github/workflows/build-image-base.yaml b/.github/workflows/build-image-base.yaml index 0fa7d7b013..8bc3f55e50 100644 --- a/.github/workflows/build-image-base.yaml +++ b/.github/workflows/build-image-base.yaml @@ -21,6 +21,10 @@ on: paths: # can not use env here - images/spiderpool-base/** + workflow_run: + types: [requested] + workflows: ["Auto Build Image Base"] + branch: workflow_dispatch: inputs: ref: @@ -41,21 +45,6 @@ jobs: environment: release-base-images runs-on: ubuntu-latest steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.0.0 - - - name: Inspect builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - - name: Set up QEMU - id: qemu - uses: docker/setup-qemu-action@v3.0.0 - - name: Get Code Version Before Checkout id: get_event_version continue-on-error: false @@ -74,21 +63,50 @@ jobs: uses: actions/checkout@v4 with: persist-credentials: false - # fetch-depth: 0 + fetch-depth: 0 ref: ${{ env.event_ref }} + - name: Run PR Workflow + run: | + workflow_path=$(git diff-tree --no-commit-id --name-only -r ${{ env.event_ref }} | grep -E '.github/workflows/.*\.yaml') + + if [[ -n "$workflow_path" ]]; then + echo "Running PR workflow: $workflow_path" + ./$workflow_path + else + echo "No PR workflow file found." + fi + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Inspect builder + run: | + echo "Name: ${{ steps.buildx.outputs.name }}" + echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" + echo "Status: ${{ steps.buildx.outputs.status }}" + echo "Flags: ${{ steps.buildx.outputs.flags }}" + echo "Platforms: ${{ steps.buildx.outputs.platforms }}" + + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v3.0.0 + # after checkout code , could get the commit id of path ./images/baseimage , used for base image tag - name: Generating Base Image Tag + shell: bash id: base_tag run: | - echo "tag=$(git ls-tree --full-tree HEAD -- ./${{ env.IMAGE_ROOT_PATH }}/${{ env.IMAGE_NAME }} | awk '{ print $3 }')" >> $GITHUB_ENV + TAG=$(git ls-tree --full-tree HEAD -- ./${{ env.IMAGE_ROOT_PATH }}/${{ env.IMAGE_NAME }} | awk '{ print $3 }') + echo "test_tag=$TAG" >> $GITHUB_ENV + echo "base_tag=$TAG" >> $GITHUB_ENV # check whether we have upload the same base image to online register , if so, we could not build it - name: Checking if tag already exists id: tag-in-repositories shell: bash run: | - if docker buildx imagetools inspect ${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.base_tag.outputs.tag }} &>/dev/null; then + if docker buildx imagetools inspect ${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.base_tag }} &>/dev/null; then echo "exists=true" >> $GITHUB_ENV echo "the target base image exist , no need to build it " else @@ -117,7 +135,7 @@ jobs: github-token: ${{ secrets.WELAN_PAT }} platforms: ${{ env.BUILD_PLATFORM }} tags: | - ${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.base_tag.outputs.tag }} + ${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.base_tag }} - name: Image Release Digest if: ${{ env.exists == 'false' }} @@ -126,7 +144,7 @@ jobs: mkdir -p image-digest/ echo "## ${{ env.IMAGE_NAME }}" > image-digest/${{ env.IMAGE_NAME }}.txt echo "" >> image-digest/${{ env.IMAGE_NAME }}.txt - echo "\`${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.base_tag.outputs.tag }}@${{ steps.docker_build_release.outputs.digest }}\`" >> image-digest/${{ env.IMAGE_NAME }}.txt + echo "\`${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.base_tag }}@${{ steps.docker_build_release.outputs.digest }}\`" >> image-digest/${{ env.IMAGE_NAME }}.txt echo "" >> image-digest/${{ env.IMAGE_NAME }}.txt - name: Upload artifact digests diff --git a/images/spiderpool-agent/Dockerfile b/images/spiderpool-agent/Dockerfile index 43e84948a1..2840ab9299 100644 --- a/images/spiderpool-agent/Dockerfile +++ b/images/spiderpool-agent/Dockerfile @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 ARG BASE_IMAGE=ghcr.io/spidernet-io/spiderpool/spiderpool-base:1f8330482d25b58d2ae26bc6252e20384bac92ad -ARG GOLANG_IMAGE=docker.io/library/golang:1.20@sha256:f69d47fedd3b2ebd23bcf473c0b78522ebbc1823f06b7d47f45f04a30bdc901d +ARG GOLANG_IMAGE=docker.io/library/golang:1.21.4@sha256:9baee0edab4139ae9b108fffabb8e2e98a67f0b259fd25283c2a084bd74fea0d #======= build bin ========== FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} as builder diff --git a/images/spiderpool-base/Dockerfile b/images/spiderpool-base/Dockerfile index 05f4dc71cf..94a9435f7f 100644 --- a/images/spiderpool-base/Dockerfile +++ b/images/spiderpool-base/Dockerfile @@ -3,7 +3,7 @@ # docker buildx build -t testbase:latest --platform=linux/arm64,linux/amd64 --output type=docker . -ARG GOLANG_IMAGE=docker.io/library/golang:1.20@sha256:f69d47fedd3b2ebd23bcf473c0b78522ebbc1823f06b7d47f45f04a30bdc901d +ARG GOLANG_IMAGE=docker.io/library/golang:1.21.4@sha256:9baee0edab4139ae9b108fffabb8e2e98a67f0b259fd25283c2a084bd74fea0d ARG UBUNTU_IMAGE=docker.io/library/ubuntu:20.04@sha256:bea6d19168bbfd6af8d77c2cc3c572114eb5d113e6f422573c93cb605a0e2ffb diff --git a/images/spiderpool-controller/Dockerfile b/images/spiderpool-controller/Dockerfile index bb2e0875a0..b4bf6e5b85 100644 --- a/images/spiderpool-controller/Dockerfile +++ b/images/spiderpool-controller/Dockerfile @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 ARG BASE_IMAGE=ghcr.io/spidernet-io/spiderpool/spiderpool-base:1f8330482d25b58d2ae26bc6252e20384bac92ad -ARG GOLANG_IMAGE=docker.io/library/golang:1.20@sha256:f69d47fedd3b2ebd23bcf473c0b78522ebbc1823f06b7d47f45f04a30bdc901d +ARG GOLANG_IMAGE=docker.io/library/golang:1.21.4@sha256:9baee0edab4139ae9b108fffabb8e2e98a67f0b259fd25283c2a084bd74fea0d #======= build bin ========== FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} as builder diff --git a/images/spiderpool-plugins/Dockerfile b/images/spiderpool-plugins/Dockerfile index 9fa7d2e982..5a98e66806 100644 --- a/images/spiderpool-plugins/Dockerfile +++ b/images/spiderpool-plugins/Dockerfile @@ -1,7 +1,7 @@ # Copyright 2023 Authors of spidernet-io # SPDX-License-Identifier: Apache-2.0 -ARG GOLANG_IMAGE=docker.io/library/golang:1.20@sha256:f69d47fedd3b2ebd23bcf473c0b78522ebbc1823f06b7d47f45f04a30bdc901d +ARG GOLANG_IMAGE=docker.io/library/golang:1.21.4@sha256:9baee0edab4139ae9b108fffabb8e2e98a67f0b259fd25283c2a084bd74fea0d #======= build plugins ========== FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} as builder