From d2be34bc61ce0b4327e3ff557cc2148da8004667 Mon Sep 17 00:00:00 2001 From: shuirong Date: Wed, 22 Oct 2025 17:53:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?ci:=20=E8=BF=BD=E5=8A=A0=20circleci=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .circleci/config.yml | 116 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..2189809 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,116 @@ +version: 2.1 +orbs: + aws-ecr: circleci/aws-ecr@7.0.0 + +jobs: + build-and-push: + machine: + image: ubuntu-2204:current + resource_class: medium + parameters: + docker-tag: + type: string + path: + type: string + repo: + type: string + dockerfile: + type: string + steps: + - aws-ecr/build-and-push-image: + checkout: true + account-url: AWS_ECR_ACCOUNT_URL + aws-access-key-id: AWS_ACCESS_KEY_ID + aws-secret-access-key: AWS_SECRET_ACCESS_KEY + create-repo: false + dockerfile: <> + path: <> + region: AWS_REGION + repo: <> + tag: '<>${CIRCLE_SHA1}' + deploy: + machine: + image: ubuntu-2204:current + resource_class: medium + parameters: + docker-tag: + type: string + path: + type: string + deploy-name: + type: string + deploy-namespace: + type: string + steps: + - run: + name: kubectl apply + command: | + CMD='/home/ubuntu/cluster-for-B/deploy.sh <> <>'${CIRCLE_SHA1}' <> <>' + echo $CMD + ssh ${USER_NAME}@${HOST_NAME} ${CMD} + + # 判断正则表达式是否匹配,匹配规则从下面的示例中提取,示例:2023.wk42,2023.wk43 + if [[ "${CIRCLE_BRANCH}" =~ ^([0-9]{4}.wk[0-9]{2},?)+$ ]]; then + curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"'${CIRCLE_USERNAME}' 触发了正式环境分支 '${CIRCLE_BRANCH}' 更新与部署"}}' https://open.larksuite.com/open-apis/bot/v2/hook/68004e4a-1381-4886-a982-cd77d5f2e6a1 + fi + # 判断正则表达式是否匹配,匹配规则从下面的示例中提取,示例:canary.2023.wk42,canary.2023.wk43 + if [[ "${CIRCLE_BRANCH}" =~ ^canary.([0-9]{4}.wk[0-9]{2},?)+$ ]]; then + curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"'${CIRCLE_USERNAME}' 触发了灰度环境分支 '${CIRCLE_BRANCH}' 更新与部署"}}' https://open.larksuite.com/open-apis/bot/v2/hook/68004e4a-1381-4886-a982-cd77d5f2e6a1 + fi + +workflows: + version: 2 + backend_build_and_push: + jobs: + - build-and-push: + name: build-for-test + context: + - ecr-new + path: . + dockerfile: Dockerfile + repo: catalog-agent + docker-tag: '' + filters: + branches: + only: + - main + - deploy: + name: deploy-for-test + docker-tag: '' + path: '/home/ubuntu/cluster-for-B/gbase-dev/catalog-agent/deploy.yaml' + deploy-name: catalog-agent + deploy-namespace: gbase-dev + context: + - ecr-new + filters: + branches: + only: + - main + requires: + - build-for-test + - build-and-push: + name: build-for-prod + context: + - ecr-new + path: . + dockerfile: Dockerfile + repo: catalog-agent + docker-tag: '' + filters: + branches: + only: + - main + - deploy: + name: deploy-for-prod + docker-tag: '' + path: '/home/ubuntu/cluster-for-B/default/catalog-agent/deploy.yaml' + deploy-name: catalog-agent + deploy-namespace: gbase-dev + context: + - ecr-new + filters: + branches: + only: + - main + requires: + - build-for-prod \ No newline at end of file From a39f8a45bcbdb0287d44f0b760a169fd3ed1ed2b Mon Sep 17 00:00:00 2001 From: shuirong Date: Wed, 22 Oct 2025 18:10:03 +0900 Subject: [PATCH 2/2] =?UTF-8?q?ci:=20=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E3=80=81=E6=AD=A3=E5=BC=8F=E7=9A=84=E5=88=86=E6=94=AF=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2189809..366bc72 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,7 +73,7 @@ workflows: filters: branches: only: - - main + - master - deploy: name: deploy-for-test docker-tag: '' @@ -85,7 +85,7 @@ workflows: filters: branches: only: - - main + - master requires: - build-for-test - build-and-push: @@ -99,7 +99,7 @@ workflows: filters: branches: only: - - main + - prod - deploy: name: deploy-for-prod docker-tag: '' @@ -111,6 +111,6 @@ workflows: filters: branches: only: - - main + - prod requires: - build-for-prod \ No newline at end of file