gpt4 book ai didi

docker - 仅在测试成功后,如何使Circle CI上传并在AWS ECS上部署镜像?

转载 作者:行者123 更新时间:2023-12-02 20:56:08 25 4
gpt4 key购买 nike

我通过Circle CI将Node.Js应用程序部署到AWS ECS。
我想先运行测试,然后再将镜像推送到存储库。但是,当前运行测试的任务与AWS ECS任务同时运行。以下是我的./circleci/config.yml文件。
如何更改此行为,以便仅在测试成功时才推送图像?

version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@6.10.0
jobs:
test:
docker:
- image: cypress/base:12.18.0
steps:
- checkout
- run: npm ci
- run: npm run cy:verify
# save npm dependencies and Cypress binary for future runs
- save_cache:
key: cache-{{ checksum "package.json" }}
paths:
- ~/.npm
- ~/.cache
- run: npm run test:ci

workflows:
version: 2.1
test:
jobs:
- test
- aws-ecr/build-and-push-image:
create-repo: true
no-output-timeout: 10m
repo: 'stage-instance'

谢谢!

最佳答案

在工作流程中添加一个require步骤以根据条件进行过滤。

version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@6.10.0
jobs:
test:
docker:
- image: cypress/base:12.18.0
steps:
- checkout
- run: npm ci
- run: npm run cy:verify
# save npm dependencies and Cypress binary for future runs
- save_cache:
key: cache-{{ checksum "package.json" }}
paths:
- ~/.npm
- ~/.cache
- run: npm run test:ci

workflows:
version: 2.1
test:
jobs:
- test
- aws-ecr/build-and-push-image:
create-repo: true
no-output-timeout: 10m
repo: 'stage-instance'
requires:
- test

关于docker - 仅在测试成功后,如何使Circle CI上传并在AWS ECS上部署镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62900717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com