From df0f467ea8da5e65fc251ccce79b4c1e9021f1bd Mon Sep 17 00:00:00 2001 From: rustdreamer Date: Wed, 2 Aug 2023 09:46:25 +0800 Subject: [PATCH] fix --- .drone.yml | 235 ++++++++++++++++++++++++++--------------------------- 1 file changed, 117 insertions(+), 118 deletions(-) diff --git a/.drone.yml b/.drone.yml index 75cdd23..3743156 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,120 +1,119 @@ --- - kind: pipeline - name: default - - volumes: - - name: dockersock - host: - path: /var/run/docker.sock +kind: pipeline +name: default + +volumes: +- name: dockersock + host: + path: /var/run/docker.sock +- name: cache + host: · + path: /tmp/cache/visitor-new-api + +steps: +- name: restore-cache + pull: if-not-exists + image: drillster/drone-volume-cache + settings: + restore: true + mount: + - ./.npm-cache + - ./node_modules + volumes: + - name: cache + path: /cache + +- name: install + image: node:14.16.1 + pull: if-not-exists + commands: + # 删除文件 npm install + # - rm -rf package-lock.json + - npm --registry https://registry.npm.taobao.org install + when: + event: [push, pull_request] + branch: [development, test, master, sso] + +- name: rebuild-cache + pull: if-not-exists + image: drillster/drone-volume-cache + settings: + rebuild: true + mount: + - ./.npm-cache + - ./node_modules + volumes: - name: cache - host: · - path: /tmp/cache/visitor-new-api - - steps: - - name: restore-cache - pull: if-not-exists - image: drillster/drone-volume-cache - settings: - restore: true - mount: - - ./.npm-cache - - ./node_modules - volumes: - - name: cache - path: /cache - - - name: install - image: node:14.16.1 - pull: if-not-exists - commands: - # 删除文件 npm install - # - rm -rf package-lock.json - - npm --registry https://registry.npm.taobao.org install - when: - event: [push, pull_request] - branch: [development, test, master, sso] - - - name: rebuild-cache - pull: if-not-exists - image: drillster/drone-volume-cache - settings: - rebuild: true - mount: - - ./.npm-cache - - ./node_modules - volumes: - - name: cache - path: /cache - - # build - - name: build - pull: if-not-exists - image: node:14.16.1 - commands: - - npm run build - when: - event: [push, pull_request] - branch: [development, test, master, sso] - - # docker-build - - name: docker-build - pull: if-not-exists - image: plugins/docker - volumes: - - name: dockersock - path: /var/run/docker.sock - settings: - repo: hub.kaiguawang.cn/longge/visitor-node-api - registry: hub.kaiguawang.cn - tags: - - latest - - '0.0.1' - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - event: [push, pull_request] - branch: [development, test, master] - - # run - - name: dev-run - image: appleboy/drone-ssh - pull: if-not-exists - settings: - host: 172.17.0.1 - username: root - password: - from_secret: ssh_password - port: 22 - command_timeout: 300s - script: - - cd /home/runtime/apps/qunsense - - docker compose up -d api - when: - event: [push, pull_request] - branch: [development] - - - name: notify - image: fifsky/drone-wechat-work - pull: if-not-exists - # pull: always - settings: - url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4166884e-9d7b-4e7a-a1c8-80d71d4755ba - msgtype: markdown - content: | - {{if eq .Status "success" }} - #### 🎉 ${DRONE_REPO} 构建成功 - > Commit: ${DRONE_COMMIT_MESSAGE} - > Author: ${DRONE_COMMIT_AUTHOR} - {{else}} - #### ❌ ${DRONE_REPO} 构建失败 - > Commit: ${DRONE_COMMIT_MESSAGE} - > Author: ${DRONE_COMMIT_AUTHOR} - > 请立即修复!!! - {{end}} - when: - status: - - failure - - success - \ No newline at end of file + path: /cache + +# build +- name: build + pull: if-not-exists + image: node:14.16.1 + commands: + - npm run build + when: + event: [push, pull_request] + branch: [development, test, master, sso] + +# docker-build +- name: docker-build + pull: if-not-exists + image: plugins/docker + volumes: + - name: dockersock + path: /var/run/docker.sock + settings: + repo: hub.kaiguawang.cn/longge/visitor-node-api + registry: hub.kaiguawang.cn + tags: + - latest + - '0.0.1' + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + event: [push, pull_request] + branch: [development, test, master] + +# run +- name: dev-run + image: appleboy/drone-ssh + pull: if-not-exists + settings: + host: 172.17.0.1 + username: root + password: + from_secret: ssh_password + port: 22 + command_timeout: 300s + script: + - cd /home/runtime/apps/qunsense + - docker compose up -d api + when: + event: [push, pull_request] + branch: [development] + +- name: notify + image: fifsky/drone-wechat-work + pull: if-not-exists + # pull: always + settings: + url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4166884e-9d7b-4e7a-a1c8-80d71d4755ba + msgtype: markdown + content: | + {{if eq .Status "success" }} + #### 🎉 ${DRONE_REPO} 构建成功 + > Commit: ${DRONE_COMMIT_MESSAGE} + > Author: ${DRONE_COMMIT_AUTHOR} + {{else}} + #### ❌ ${DRONE_REPO} 构建失败 + > Commit: ${DRONE_COMMIT_MESSAGE} + > Author: ${DRONE_COMMIT_AUTHOR} + > 请立即修复!!! + {{end}} + when: + status: + - failure + - success