新增版本控制
This commit is contained in:
219
20260609.yaml
Normal file
219
20260609.yaml
Normal file
@@ -0,0 +1,219 @@
|
||||
# 20260609部署开发环境后的后端
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: CI-Stage
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
GOPROXY: https://goproxy.cn,direct
|
||||
GONOPROXY: gitea.bluettipower.com
|
||||
GOPRIVATE: gitea.bluettipower.com/*
|
||||
|
||||
steps:
|
||||
- name: CI-building
|
||||
environment:
|
||||
ENV: ""
|
||||
API_URL: dev-api.essmonitor.com
|
||||
IMAGE_URL: harbor.bluettipower.com
|
||||
GIT_COMMIT: ${DRONE_COMMIT:0:10}
|
||||
GOPROXY: https://goproxy.cn,direct
|
||||
GONOPROXY: gitea.bluettipower.com
|
||||
GOPRIVATE: gitea.bluettipower.com
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /root/go
|
||||
PROJECT_API_NAME:
|
||||
from_secret: PROJECT_API_NAME
|
||||
PROJECT_RPC_NAME:
|
||||
from_secret: PROJECT_RPC_NAME
|
||||
DOMAIN_PREFIX:
|
||||
from_secret: STAGE_DOMAIN_PREFIX
|
||||
command_timeout: 160s
|
||||
commands:
|
||||
- pwd
|
||||
- ping -c 1 gitea.bluettipower.com
|
||||
- git config --global url."https://pywee:Qiu118199@gitea.bluettipower.com".insteadOf "https://gitea.bluettipower.com"
|
||||
# - git config --global url."https://admin:cjJXBbkHlvVWH2B@gitea.bluettipower.com".insteadOf "https://gitea.bluettipower.com"
|
||||
- cd /bluetti/app_project/
|
||||
- |
|
||||
if [ ! -d ${DRONE_REPO_NAME} ]; then
|
||||
git clone https://gitea.bluettipower.com/bluettipower/${DRONE_REPO_NAME}.git ${DRONE_REPO_NAME}
|
||||
fi
|
||||
- cd ${DRONE_REPO_NAME}
|
||||
- git checkout -- .
|
||||
- git fetch origin
|
||||
- git switch ${DRONE_COMMIT_BRANCH}
|
||||
- git pull
|
||||
- export PATH=$PATH:/usr/local/go/bin
|
||||
- go env
|
||||
- go version
|
||||
- go mod tidy
|
||||
- go build -ldflags="-s -w -X 'gitea.bluettipower.com/bluettipower/zerocommon/dingtalk.envVars=${DRONE_COMMIT:0:10};${DRONE_BUILD_NUMBER};${DRONE_COMMIT_AUTHOR};${DRONE_COMMIT_AUTHOR_EMAIL};${DRONE_REPO_NAME};https://drone.bluettipower.com/Bluettipower/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER};$PROJECT_API_NAME'" -o ./app api/*.go
|
||||
- echo "API构建完成"
|
||||
- |
|
||||
if [ -d "rpc" ]; then
|
||||
go build -ldflags="-s -w -X 'gitea.bluettipower.com/bluettipower/zerocommon/dingtalk.envVars=${DRONE_COMMIT:0:10};${DRONE_BUILD_NUMBER};${DRONE_COMMIT_AUTHOR};${DRONE_COMMIT_AUTHOR_EMAIL};${DRONE_REPO_NAME};https://drone.bluettipower.com/Bluettipower/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER};$PROJECT_RPC_NAME'" -o ./rpc_app rpc/*.go
|
||||
echo "RPC构建完成"
|
||||
echo "${DRONE_COMMIT:0:10}"
|
||||
fi
|
||||
# - docker compose down
|
||||
- docker compose build --no-cache
|
||||
- docker compose up -d --force-recreate
|
||||
- rm -rf ./rpc_app && rm -rf ./app
|
||||
|
||||
volumes:
|
||||
- name: docker-sock
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- develop
|
||||
event:
|
||||
include:
|
||||
- push
|
||||
- merge_request
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: CI-Prod
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
GOPROXY: https://proxy.golang.com.cn,direct
|
||||
GONOPROXY: gitea.bluettipower.com
|
||||
GOPRIVATE: gitea.bluettipower.com
|
||||
|
||||
steps:
|
||||
- name: CI-building
|
||||
environment:
|
||||
ENV: ""
|
||||
IMAGE_URL: harbor.bluettipower.com
|
||||
API_URL: api.bluettipower.com
|
||||
GIT_COMMIT: ${DRONE_COMMIT:0:10}
|
||||
GOPROXY: https://proxy.golang.com.cn,direct
|
||||
GONOPROXY: gitea.bluettipower.com
|
||||
GOPRIVATE: gitea.bluettipower.com
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /root/go
|
||||
PROJECT_API_NAME:
|
||||
from_secret: PROJECT_API_NAME
|
||||
PROJECT_RPC_NAME:
|
||||
from_secret: PROJECT_RPC_NAME
|
||||
DOMAIN_PREFIX:
|
||||
from_secret: STAGE_DOMAIN_PREFIX
|
||||
command_timeout: 360s
|
||||
commands:
|
||||
- pwd
|
||||
- ping -c 1 gitea.bluettipower.com
|
||||
- git config --global url."https://pywee:Qiu118199@gitea.bluettipower.com".insteadOf "https://gitea.bluettipower.com"
|
||||
# - git config --global url."https://admin:cjJXBbkHlvVWH2B@gitea.bluettipower.com".insteadOf "https://gitea.bluettipower.com"
|
||||
- cd /bluetti/app_project/
|
||||
- |
|
||||
if [ ! -d ${DRONE_REPO_NAME} ]; then
|
||||
git clone https://gitea.bluettipower.com/bluettipower/${DRONE_REPO_NAME}.git ${DRONE_REPO_NAME}
|
||||
fi
|
||||
- cd ${DRONE_REPO_NAME}
|
||||
- git checkout -- .
|
||||
- git fetch origin
|
||||
- git switch ${DRONE_COMMIT_BRANCH}
|
||||
- git pull
|
||||
#- git branch --set-upstream-to=origin/${DRONE_COMMIT_BRANCH} ${DRONE_COMMIT_BRANCH}
|
||||
# - git pull https://pywee:$${GIT_PWD}@gitea.bluettipower.com/Bluettipower/${DRONE_REPO_NAME}.git
|
||||
- export PATH=$PATH:/usr/local/go/bin
|
||||
- go mod tidy
|
||||
- go build -ldflags="-s -w -X 'gitea.bluettipower.com/bluettipower/zerocommon/dingtalk.envVars=${DRONE_COMMIT:0:10};${DRONE_BUILD_NUMBER};${DRONE_COMMIT_AUTHOR};${DRONE_COMMIT_AUTHOR_EMAIL};${DRONE_REPO_NAME};https://drone.bluettipower.com/Bluettipower/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER};$PROJECT_API_NAME'" -o ./app api/*.go
|
||||
- docker build -f api/Dockerfile -t $${PROJECT_API_NAME}:latest .
|
||||
#- sudo docker login harbor.bluettipower.com -u admin -p cjJXBbkHlvVWH2B
|
||||
- sudo docker login harbor.bluettipower.com -u bluetti -p cjJXBbkHlvVWH2B
|
||||
- docker tag $${PROJECT_API_NAME}:latest harbor.bluettipower.com/bluetti/$${PROJECT_API_NAME}:${DRONE_COMMIT:0:10}
|
||||
- sudo docker push harbor.bluettipower.com/bluetti/$${PROJECT_API_NAME}:${DRONE_COMMIT:0:10}
|
||||
- echo "API构建完成, 你可以通过 docker pull harbor.bluettipower.com/bluetti/$PROJECT_API_NAME:${DRONE_COMMIT:0:10} 获取镜像"
|
||||
- rm -rf ./app
|
||||
- |
|
||||
if [ -d "rpc" ]; then
|
||||
go build -ldflags="-s -w -X 'gitea.bluettipower.com/bluettipower/zerocommon/dingtalk.envVars=${DRONE_COMMIT:0:10};${DRONE_BUILD_NUMBER};${DRONE_COMMIT_AUTHOR};${DRONE_COMMIT_AUTHOR_EMAIL};${DRONE_REPO_NAME};https://drone.bluettipower.com/Bluettipower/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER};$PROJECT_RPC_NAME'" -o ./rpc_app rpc/*.go
|
||||
docker build -f rpc/Dockerfile -t $${PROJECT_RPC_NAME}:latest .
|
||||
docker tag $${PROJECT_RPC_NAME}:latest harbor.bluettipower.com/bluetti/$${PROJECT_RPC_NAME}:${DRONE_COMMIT:0:10}
|
||||
sudo docker push harbor.bluettipower.com/bluetti/$${PROJECT_RPC_NAME}:${DRONE_COMMIT:0:10}
|
||||
rm -rf ./rpc_app
|
||||
echo "RPC构建完成, 你可以通过 docker pull harbor.bluettipower.com/bluetti/$${PROJECT_RPC_NAME}:${DRONE_COMMIT:0:10} 获取镜像"
|
||||
echo "${DRONE_COMMIT:0:10}"
|
||||
fi
|
||||
|
||||
volumes:
|
||||
- name: docker-sock
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
include:
|
||||
- push
|
||||
- merge_request
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: CI-notify
|
||||
|
||||
depends_on:
|
||||
- CI-Prod
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
steps:
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
host: smtp.qiye.aliyun.com
|
||||
username: alanal@poweroak.com
|
||||
password: KRLdCsdDGrI8Uko
|
||||
port: 465
|
||||
from: alanal@poweroak.com
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
status:
|
||||
- failure
|
||||
event:
|
||||
- merge_request
|
||||
|
||||
# - name: send-dingtalk-notification
|
||||
#image: lddsb/drone-dingtalk-message
|
||||
#volumes:
|
||||
#- name: dingtalk-tpl
|
||||
#path: /data
|
||||
#settings:
|
||||
#token: 95b118a31f95c328b1c5f7f52622997d77b69da9d393b0700fc8eb33ed551713
|
||||
#secret: SECb355ff4ba5b05b5325d4c67d3f6637c75613668c248ad9cc97355fe266fe1b6a
|
||||
## token: 8a47605751760b1b1af660e67c2f39bdf9f83c672a18ab872412e99c78b0e5c0
|
||||
## secret: SEC0dfa30e4e8acfae69e7bf42b19c2feff5d302d2667de3aa4ba8cff46e867758a
|
||||
#type: markdown
|
||||
#debug: false
|
||||
#tpl: /data/dingtalk_${DRONE_BUILD_EVENT}.tpl
|
||||
#tips_title: 后端上线通知
|
||||
#when:
|
||||
#status:
|
||||
#- success
|
||||
#event:
|
||||
#- promote
|
||||
#branch:
|
||||
#- master
|
||||
|
||||
volumes:
|
||||
- name: dingtalk-tpl
|
||||
host:
|
||||
path: /bluetti/drone/data
|
||||
Reference in New Issue
Block a user