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 environment: a: 1 volumes: - name: dockersock host: path: /data/drone/docker/sock - name: node host: path: /data/drone/node_modules-project-iot-qmgo - name: localtime host: path: /etc/localtime 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: # GOOS: linux GITEA_TOKEN: from_secret: gitea_token # command: [ "--tagFormat", "test_${version}" ] settings: git_login: from_secret: gitea_username git_password: from_secret: gitea_password - name: test分支获取master信息 image: alpine/git:v2.36.2 commands: - git fetch origin test - git checkout test - git merge origin/master - git commit --amend -m "[skip ci]从master合并历史到test" - git branch --set-upstream-to=origin/test test - git pull - git push --set-upstream origin test - git checkout master when: branch: - master - name: 获取tag数据 image: alpine/git:v2.36.2 settings: username: from_secret: gitea_username password: from_secret: gitea_password commands: - echo "https://${username}:${password}@git.1000my.com" >> ~/.git-credentials - cat ~/.git-credentials - 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 volumes: - name: node path: /drone/src/node_modules settings: mirror: https://docker.mirrors.ustc.edu.cn commands: - ln -s /usr/bin/python2 /usr/bin/python - python --version - npm config set registry https://registry.npm.taobao.org - npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ - cd ./src/base_mobile_map_sdk - npm install - cd ../../ - npm install - npm run build when: branch: - dev - test - master - name: 平台级对象存储cdn部署dev pull: if-not-exists image: swr.cn-east-3.myhuaweicloud.com/drone/mysql:mysql-8.0.29-backup environment: obs_key: from_secret: obs_key obs_secret: from_secret: obs_secret commands: - sed -i "s@https://.*"@https://iot-${DRONE_BRANCH}.123.1000my.com"@" build/public/config.json - obsutil mkdir obs://qianmu-iot/base_qmgo_react-${DRONE_BRANCH}/ - obsutil config -i=$obs_key -k=$obs_secret -e=obs.cn-east-2.myhuaweicloud.com - obsutil cp -r -f -flat build obs://qianmu-iot/base_qmgo_react-${DRONE_BRANCH}/ when: branch: - dev - test - name: 正式环境-平台级对象存储cdn部署 pull: if-not-exists image: swr.cn-east-3.myhuaweicloud.com/drone/mysql:mysql-8.0.29-backup environment: obs_key: from_secret: obs_key obs_secret: from_secret: obs_secret commands: - sed -i "s@https://.*"@https://iot.1000my.com"@" build/public/config.json - obsutil mkdir obs://qianmu-iot/base_qmgo_react/ - obsutil config -i=$obs_key -k=$obs_secret -e=obs.cn-east-2.myhuaweicloud.com - obsutil cp -r -f -flat build obs://qianmu-iot/base_qmgo_react/ 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]