From a87874f380f144c23cf4cbdf47f5cab0aadfc931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E5=9B=BD=E5=AE=89?= Date: Mon, 5 Jun 2023 14:41:51 +0800 Subject: [PATCH] fix: cicd --- .dockerignore | 3 ++ .drone.yml | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++ .releaserc | 51 ++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 .dockerignore create mode 100644 .drone.yml create mode 100644 .releaserc diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4b4e931 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!build +!nginx.conf \ No newline at end of file diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..4dd330b --- /dev/null +++ b/.drone.yml @@ -0,0 +1,140 @@ +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 + commands: + - 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 + volumes: + - name: node + path: /drone/src/node_modules + settings: + mirror: https://docker.mirrors.ustc.edu.cn + commands: + - 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] diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..cce948d --- /dev/null +++ b/.releaserc @@ -0,0 +1,51 @@ +{ + "branches": [ + "master", + { + "name": "test", + "prerelease": "beta" + }, + "test", + { + "name": "dev", + "prerelease": "pre-dev" + } + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "angular", + "releaseRules": [ + { + "type": "docs", + "scope": "README", + "release": "patch" + }, + { + "type": "refactor", + "release": "patch" + }, + { + "type": "style", + "release": "patch" + } + ], + "parserOpts": { + "noteKeywords": [ + "BREAKING CHANGE", + "BREAKING CHANGES" + ] + } + } + ], + "@semantic-release/release-notes-generator", + [ + "@saithodev/semantic-release-gitea", + { + "giteaUrl": "https://git.1000my.com", + "assets": [] + } + ] + ] +}