fastapi-template/.gitlab-ci.yml

43 lines
1.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

variables:
PROJECT_NAME: fastapi_app_template
DOCKER_IMAGE_DOMAIN: 192.168.2.237:8088
LATEST_VERSION: latest
K8S_NS: default
DEPLOYMENT_NAME: fastapi-app-template
before_script:
- PATH=.:$PATH
- IMAGE_NAME=${DOCKER_IMAGE_DOMAIN}/library/${PROJECT_NAME}:${LATEST_VERSION}
stages:
- build
- deploy
build-staging:dep:
stage: build
only:
- master
tags:
- master
script:
- echo "===== start build =========="
- docker build -t ${IMAGE_NAME} .
- docker push ${IMAGE_NAME}
- docker rmi ${IMAGE_NAME}
- echo "===== end build !!!!!! ====="
deploy-staging:dep:
stage: deploy
only:
- master
tags:
- master
script:
- echo "===== start deploy =========="
- echo $CI_COMMIT_TAG
- # 判断当前分支是否为dev开发分支否则不重启容器服务
- if [[ $CI_COMMIT_TAG == 'dev' ]] && [[ "$(kubectl get deployment -n $K8S_NS | grep $DEPLOYMENT_NAME | awk '{print $1}')" ]]; then
- kubectl rollout restart deployment $DEPLOYMENT_NAME -n $K8S_NS
- fi
- echo "===== end deploy !!!!!======="