include: # 包含node、git的远程开发流水线模版 - .node-git-dev.yml .upload_plugin_info: &upload_plugin_info - docker: image: cnbcool/default-env stages: - name: install script: npm install --production --registry http://mirrors.cloud.tencent.com/npm/ - name: download plugin files if: | [ "$CNB_EVENT" = "api_trigger_upload_plugin_info" ] script: node ./src/down.js -token=$CNB_TOKEN -path=$PLUGIN_PATH -slug=$API_TRIGGER_REPO_SLUG -ref=$API_TRIGGER_BRANCH - name: gather plugins script: node ./src/gather.js -prefix=$CNB_WEB_ENDPOINT/$CNB_REPO_SLUG/-/git/raw/$CNB_BRANCH/plugins/ -ref=$API_TRIGGER_BRANCH - name: commit plugins if: | git_status=$(git status --porcelain) echo "$git_status" if [[ -n $git_status ]]; then exit 0 else exit 1 fi jobs: - name: commit plugin image: tencentcom/git-commit settings: add: - plugins commitMessage: "commit plugin info by ci [skip ci]" exports: branch: COMMIT_BRANCH - name: create pr image: cnbcool/create-pr settings: target_branch: $CNB_BRANCH head_branch: $COMMIT_BRANCH title: "commit plugin info" .trans-image-to-dockerhub: &trans-image-to-dockerhub - imports: https://cnb.cool/cnb/secrets/-/blob/main/envs/hub.docker.com.yml services: - docker stages: - name: show trigger info script: echo $API_TRIGGER_REPO_SLUG $IMAGE_VERSION - name: set DOCKERHUB_IMAGE_NAME script: | content=$(cat slug-image-map.txt) # 使用 awk 进行匹配和提取 value=$(echo "$content" | awk -F "=" -v slug="$API_TRIGGER_REPO_SLUG" '$1 == slug {print $2}') # 根据条件判断输出结果 if [[ -n "$value" ]]; then echo -e "$value" else echo -e "" fi exports: info: DOCKERHUB_IMAGE_NAME - name: set DOCKERHUB_IMAGE_TAG script: echo $DOCKERHUB_IMAGE_NAME:$IMAGE_VERSION exports: info: DOCKERHUB_IMAGE_TAG - name: pull plugin image script: - docker login -u ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${IMAGE_DOCKER_REGISTRY} - docker pull $IMAGE_TAG-linux-amd64 - docker pull $IMAGE_TAG-linux-arm64 - docker tag $IMAGE_TAG-linux-amd64 $DOCKERHUB_IMAGE_TAG-linux-amd64 - docker tag $IMAGE_TAG-linux-arm64 $DOCKERHUB_IMAGE_TAG-linux-arm64 - docker login -u ${DOCKER_USER} -p "${DOCKER_PWD}" - docker push $DOCKERHUB_IMAGE_TAG-linux-amd64 - docker push $DOCKERHUB_IMAGE_TAG-linux-arm64 - name: manifest image: plugins/manifest settings: username: $DOCKER_USER password: $DOCKER_PWD target: $DOCKERHUB_IMAGE_TAG template: ${DOCKERHUB_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 - ${DOCKERHUB_IMAGE_TAG}-linux-amd64 - ${DOCKERHUB_IMAGE_TAG}-linux-arm64 main: push: *upload_plugin_info api_trigger_upload_plugin_info: *upload_plugin_info api_trigger_trans_image_to_dockerhub: *trans-image-to-dockerhub dev: api_trigger_trans_image_to_dockerhub: *trans-image-to-dockerhub