kind: pipeline type: docker name: 程序部署 host_aliases: - ip: 192.168.0.2 hostnames: - git.1000my.com clone: pull: if-not-exists depth: 1 trigger: branch: - test - master - dev event: - push volumes: - name: dockersock host: path: /data/drone/docker/sock - name: node host: path: /data/drone/node_modules-project-iot-qmgo steps: # 从dev合并到test 从dev合并到master - name: 生成Release版本 pull: if-not-exists # image: exment/drone-semantic-release:latest image: registry.cn-hangzhou.aliyuncs.com/tgabc-namespace/tgabc:semantic-release-v21.0.1 environment: GITEA_TOKEN: from_secret: "gitea_token" USER: from_secret: "gitea_username" PASSWD: from_secret: "gitea_password" obs_key: from_secret: "obs_key" obs_secret: from_secret: "obs_secret" settings: git_login: from_secret: gitea_username git_password: from_secret: gitea_password - name: 获取tag数据 image: alpine/git:v2.36.2 environment: GITEA_TOKEN: from_secret: "gitea_token" USER: from_secret: "gitea_username" PASSWD: from_secret: "gitea_password" obs_key: from_secret: "obs_key" obs_secret: from_secret: "obs_secret" commands: - git config --global credential.helper store - echo "https://$USER:$PASSWD@git.1000my.com" >> ~/.git-credentials - env - git fetch --tags - git submodule init - git submodule update --recursive --remote # - git submodule add -b master https://git.1000my.com/project_runteng/server_iot-common.git # - git mv server_iot-common iot-common # - git submodule sync - git describe --tags `git rev-list --tags --max-count=1` # 获取当前分支的tag - git describe --abbrev=0 --tags > .tags - cat .tags # - git fetch --tags # - git describe --tags `git rev-list --tags --max-count=1` > .tags # - cat .tags - name: 代码构建 pull: if-not-exists image: registry.k8s.1000my.com/library/node:16.15.0-slim # image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:node-14-slim-python2_3 environment: GITEA_TOKEN: from_secret: "gitea_token" USER: from_secret: "gitea_username" PASSWD: from_secret: "gitea_password" obs_key: from_secret: "obs_key" obs_secret: from_secret: "obs_secret" volumes: - name: node path: /drone/src/node_modules settings: mirror: https://docker.mirrors.ustc.edu.cn commands: - npm config set registry https://registry.npmmirror.com/ - npm config set sass_binary_site https://cdn.npmmirror.com/binaries/node-sass - cd ./src/qmmap - npm install - cd ../../ - npm install - unset CI - npm run build when: branch: - dev - test - master - name: 平台级对象存储cdn部署dev pull: if-not-exists image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:mysqlinit-base-python environment: GITEA_TOKEN: from_secret: "gitea_token" USER: from_secret: "gitea_username" PASSWD: from_secret: "gitea_password" obs_key: from_secret: "obs_key" obs_secret: from_secret: "obs_secret" cdn_url: https://qianmu-iot.1000my.com/ commands: # - sed -i "s@https://.*"@https://iot-${DRONE_BRANCH}.123.1000my.com"@" build/public/config.json - obsutil config -i=$obs_key -k=$obs_secret -e=obs.cn-east-2.myhuaweicloud.com - obsutil mkdir obs://qianmu-iot/${DRONE_REPO_NAME}-${DRONE_BRANCH}/ - obsutil cp -r -f -flat build obs://qianmu-iot/${DRONE_REPO_NAME}-${DRONE_BRANCH}/ when: branch: - dev - test - name: 正式环境-平台级对象存储cdn部署 pull: if-not-exists image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:mysqlinit-base-python environment: GITEA_TOKEN: from_secret: "gitea_token" USER: from_secret: "gitea_username" PASSWD: from_secret: "gitea_password" obs_key: from_secret: "obs_key" obs_secret: from_secret: "obs_secret" cdn_url: https://qianmu-iot.1000my.com/ commands: # - sed -i "s@https://.*"@https://iot.1000my.com"@" build/public/config.json - obsutil config -i=$obs_key -k=$obs_secret -e=obs.cn-east-2.myhuaweicloud.com - obsutil mkdir obs://qianmu-iot/${DRONE_REPO_NAME}/ - obsutil cp -r -f -flat build obs://qianmu-iot/${DRONE_REPO_NAME}/ when: branch: - master - name: cdn缓存刷新dev test pull: if-not-exists image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:qmugo_cdn_flush environment: GITEA_TOKEN: from_secret: "gitea_token" USER: from_secret: "gitea_username" PASSWD: from_secret: "gitea_password" obs_key: from_secret: "obs_key" obs_secret: from_secret: "obs_secret" cdn_url: https://qianmu-iot.1000my.com/ commands: - export cdn_url=https://qianmu-iot.1000my.com/${DRONE_REPO_NAME}-${DRONE_BRANCH}/ - /cdn.bin when: branch: - dev - test - name: cdn缓存刷新 master pull: if-not-exists image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:qmugo_cdn_flush environment: GITEA_TOKEN: from_secret: "gitea_token" USER: from_secret: "gitea_username" PASSWD: from_secret: "gitea_password" obs_key: from_secret: "obs_key" obs_secret: from_secret: "obs_secret" cdn_url: https://qianmu-iot.1000my.com/ commands: - export cdn_url=https://qianmu-iot.1000my.com/${DRONE_REPO_NAME}/ - /cdn.bin when: branch: - master - name: dingTalk notification pull: if-not-exists image: lddsb/drone-dingtalk-message failure: ignore settings: token: 11d0cb39a082a1799c7543343a72cbd76c483eba29842fa40e60642c38a53ea8 type: markdown message_color: true message_pic: true sha_link: true tips_title: "${CI_REPO_NAME}" debug: true success_color: "008000" failure_color: "FF0000" tpl_repo_short_name: "${CI_REPO_NAME}" msg_at_mobiles: "@${CI_COMMIT_AUTHOR_NAME}" success_pic: "https://raw.githubusercontent.com/Ethan-Liuu/picture/master/success.png" failure_pic: "https://raw.githubusercontent.com/Ethan-Liuu/picture/master/failed.png" tpl: "http://get.k8s.1000my.com/.shell/.tpl" when: status: [failure, success]