此CI/CD配置文件无法直接创建lambda,可以在lambda创建后实现:
- 代码更新
- 版本发布
- 切换别名
$CI_PROJECT_NAME 需要和Lambda function name 相同,否则手动修改即可。
Runner 需要安装如下库:
.gitlab-ci.yml
stages:
- deploy
- publishVersion
- updateAlias
deploy:
stage: deploy
tags:
- linux
script:
- dotnet lambda deploy-function $CI_PROJECT_NAME
only:
- tags
publishVersion:
stage: publishVersion
script:
- echo `aws lambda publish-version --function-name $CI_PROJECT_NAME --description $CI_COMMIT_TAG | jq -r .Version` > version
- sleep 5s
artifacts:
paths:
- version
only:
- tags
updateAlias:
stage: updateAlias
script:
- aws lambda update-alias --function-name $CI_PROJECT_NAME --name prod --function-version $(cat version)
only:
- tags
网友评论