.make-image-envs: &make-image-envs - name: down map # 把公开的字典文件下下来,供后续解析使用 script: curl -sSL https://cnb.cool/cnb/plugins/market/-/git/raw/main/slug-image-map.txt > slug-image-map.txt - name: set IMAGE_NAME script: | content=$(cat slug-image-map.txt) # 使用 awk 进行匹配和提取 value=$(echo "$content" | awk -F "=" -v slug="$CNB_REPO_SLUG" '$1 == slug {print $2}') # 根据条件判断输出结果 if [[ -n "$value" ]]; then echo -e "$value" else echo -e "" fi exports: info: IMAGE_NAME - name: set IMAGE_VERSION script: echo -n "$CNB_BRANCH" | cut -d "/" -f1 exports: info: IMAGE_VERSION - name: use latest if main if: | [ "$CNB_BRANCH" = "main" ] script: echo -n "latest" exports: info: IMAGE_VERSION - name: set IMAGE_TAG script: echo -n "${IMAGE_NAME}:${IMAGE_VERSION}" exports: info: IMAGE_TAG .build-by-arch: &build-by-arch - name: docker login for index.docker.io script: docker login -u "$DOCKER_USER" -p "$DOCKER_PWD" imports: https://cnb.cool/cnb/secrets/-/blob/main/envs/hub.docker.com.yml - name: set DOCKERFILE_DIR script: | if [ -f "docker/Dockerfile.linux.$BUILD_ARCH" ]; then echo -n "docker/Dockerfile.linux.$BUILD_ARCH" else echo -n "Dockerfile" fi exports: info: DOCKERFILE_DIR - name: docker build & push if: | [ -f $DOCKERFILE_DIR ] script: - docker build -f $DOCKERFILE_DIR -t $IMAGE_TAG-linux-$BUILD_ARCH . - docker push $IMAGE_TAG-linux-$BUILD_ARCH - name: resolve type: cnb:resolve options: key: build-$BUILD_ARCH .amd64-arch-build: &amd64-arch-build name: build-amd64 runner: tags: cnb:arch:amd64 services: - docker env: BUILD_ARCH: amd64 stages: - *make-image-envs - *build-by-arch .arm64-arch-build: &arm64-arch-build name: build-arm64 runner: tags: cnb:arch:arm64:v8 env: BUILD_ARCH: arm64 services: - docker stages: - *make-image-envs - *build-by-arch .multi-arch-push: &multi-arch-push - name: docker login for index.docker.io script: docker login -u "$DOCKER_USER" -p "$DOCKER_PWD" - name: await the amd64 type: cnb:await options: key: build-amd64 - name: await the arm64 type: cnb:await options: key: build-arm64 - name: manifest image: plugins/manifest settings: username: $DOCKER_USER password: $DOCKER_PWD target: $IMAGE_TAG template: ${IMAGE_TAG}-OS-ARCH # ignore_missing: true platforms: - linux/amd64 - linux/arm64 - name: clear image: lumir/remove-dockerhub-tag args: - --user - $DOCKER_USER - --password - $DOCKER_PWD - ${IMAGE_TAG}-linux-amd64 - ${IMAGE_TAG}-linux-arm64 "(main|dev|staging)": push: - *amd64-arch-build - *arm64-arch-build - name: conbine-arch imports: https://cnb.cool/cnb/secrets/-/blob/main/envs/hub.docker.com.yml services: - docker stages: - *make-image-envs - *multi-arch-push $: tag_push: - *amd64-arch-build - *arm64-arch-build - name: conbine-arch imports: https://cnb.cool/cnb/secrets/-/blob/main/envs/hub.docker.com.yml services: - docker stages: - *make-image-envs - *multi-arch-push