From 599a08092a1413b054f30dbd79bd28aa7c825b60 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Wed, 1 Nov 2023 10:00:48 +0800 Subject: [PATCH] feat: add builder and runner multi arch packaging (#1773) Signed-off-by: Qi Zhang --- .github/scripts/push-arch.sh | 39 +++++++++++-- .../workflows/bulider_runner_packaging.yml | 55 +++++++++++++++++++ 2 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/bulider_runner_packaging.yml diff --git a/.github/scripts/push-arch.sh b/.github/scripts/push-arch.sh index 8447f3db89..699821ebc7 100644 --- a/.github/scripts/push-arch.sh +++ b/.github/scripts/push-arch.sh @@ -126,10 +126,41 @@ function push_arch_dind { docker manifest push "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/rainbond:${RBD_VER/-release}-dind-allinone" } -docker login "${DOMESTIC_NAME}" -u "$DOMESTIC_DOCKER_USERNAME" -p "$DOMESTIC_DOCKER_PASSWORD" +function push_arch_runner { + docker pull "$IMAGE_NAMESPACE/runner:${RBD_VER}" || exit 1 + docker tag "$IMAGE_NAMESPACE/runner:${RBD_VER}" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}-amd64" + docker push "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}-amd64" + + docker pull "$IMAGE_NAMESPACE/runner:${RBD_VER}-arm64" || exit 1 + docker tag "$IMAGE_NAMESPACE/runner:${RBD_VER}-arm64" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}-arm64" + docker push "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}-arm64" + + docker manifest rm "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}" + docker manifest create "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}-amd64" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}-arm64" + docker manifest push "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/runner:${RBD_VER}" +} + +function push_arch_builder { + docker pull "$IMAGE_NAMESPACE/builder:${RBD_VER}" || exit 1 + docker tag "$IMAGE_NAMESPACE/builder:${RBD_VER}" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}-amd64" + docker push "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}-amd64" -push_arch + docker pull "$IMAGE_NAMESPACE/builder:${RBD_VER}-arm64" || exit 1 + docker tag "$IMAGE_NAMESPACE/builder:${RBD_VER}-arm64" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}-arm64" + docker push "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}-arm64" -push_arch_allinone + docker manifest rm "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}" + docker manifest create "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}-amd64" "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}-arm64" + docker manifest push "$DOMESTIC_NAME/$DOMESTIC_NAMESPACE/builder:${RBD_VER}" +} + +docker login "${DOMESTIC_NAME}" -u "$DOMESTIC_DOCKER_USERNAME" -p "$DOMESTIC_DOCKER_PASSWORD" -push_arch_dind \ No newline at end of file +if [ "$1" = "builder-runner" ]; then + push_arch_runner + push_arch_builder +else + push_arch + push_arch_allinone + push_arch_dind +fi \ No newline at end of file diff --git a/.github/workflows/bulider_runner_packaging.yml b/.github/workflows/bulider_runner_packaging.yml new file mode 100644 index 0000000000..cbb2eec6a5 --- /dev/null +++ b/.github/workflows/bulider_runner_packaging.yml @@ -0,0 +1,55 @@ +name: builder runner packaging +on: + repository_dispatch: + types: + - runner-builder + +env: + VERSION: ${{ github.event.client_payload.version }} + +jobs: + build-runner: + runs-on: ${{ github.event.client_payload.os }} + environment: ${{ github.event.client_payload.environment }} + steps: + - name: Pull code and Build the Docker image + env: + DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + git clone -b ${{ github.event.client_payload.branch }} ${{ github.event.client_payload.clone_url }}/runner.git + cd runner + chmod +x ./release.sh + ./release.sh + + build-builder: + runs-on: ${{ github.event.client_payload.os }} + environment: ${{ github.event.client_payload.environment }} + steps: + - name: Pull code and Build the Docker image + env: + DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + git clone -b ${{ github.event.client_payload.branch }} ${{ github.event.client_payload.clone_url }}/builder.git + cd builder + chmod +x ./release.sh + ./release.sh + + push-arch: + if: github.event.client_payload.os == 'self-hosted' + needs: [build-runner,build-builder] + runs-on: ${{ github.event.client_payload.os }} + environment: release-arch + steps: + - uses: actions/checkout@v2 + - name: push arch images + env: + RBD_VER: ${{ vars.RBD_VER }} + DOMESTIC_DOCKER_USERNAME: ${{ vars.DOMESTIC_DOCKER_USERNAME }} + DOMESTIC_DOCKER_PASSWORD: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }} + PUSH_ARCH: ${{ vars.PUSH_ARCH }} + run: | + if [ $PUSH_ARCH == 'true' ];then + chmod +x .github/scripts/push-arch.sh && ./.github/scripts/push-arch.sh builder-runner + fi \ No newline at end of file