AWS Lambda 基于GitLab的简易CI/CD (Pyt
2024-01-30 本文已影响0人
ZeroWang
此CI/CD配置文件无法直接创建lambda,可以在lambda创建后实现:
- 代码更新
- 版本发布
- 切换别名
Runner 需要安装如下库:
- dotnet
- jq
.gitlab-ci.yml
stages:
- deploy
- publishVersion
- updateAlias
deploy:
stage: deploy
tags:
- linux
script:
- dotnet lambda deploy-function gitlab-lambda-cicd-test-net6
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