rustdreamer 3 years ago
parent b312dcd929
commit df0f467ea8

@ -1,120 +1,119 @@
--- ---
kind: pipeline kind: pipeline
name: default name: default
volumes: volumes:
- name: dockersock - name: dockersock
host: host:
path: /var/run/docker.sock path: /var/run/docker.sock
- name: cache - name: cache
host: · host: ·
path: /tmp/cache/visitor-new-api 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 steps:
image: node:14.16.1 - name: restore-cache
pull: if-not-exists pull: if-not-exists
commands: image: drillster/drone-volume-cache
# 删除文件 npm install settings:
# - rm -rf package-lock.json restore: true
- npm --registry https://registry.npm.taobao.org install mount:
when: - ./.npm-cache
event: [push, pull_request] - ./node_modules
branch: [development, test, master, sso] volumes:
- name: cache
path: /cache
- name: rebuild-cache - name: install
pull: if-not-exists image: node:14.16.1
image: drillster/drone-volume-cache pull: if-not-exists
settings: commands:
rebuild: true # 删除文件 npm install
mount: # - rm -rf package-lock.json
- ./.npm-cache - npm --registry https://registry.npm.taobao.org install
- ./node_modules when:
volumes: event: [push, pull_request]
- name: cache branch: [development, test, master, sso]
path: /cache
# build - name: rebuild-cache
- name: build pull: if-not-exists
pull: if-not-exists image: drillster/drone-volume-cache
image: node:14.16.1 settings:
commands: rebuild: true
- npm run build mount:
when: - ./.npm-cache
event: [push, pull_request] - ./node_modules
branch: [development, test, master, sso] volumes:
- name: cache
path: /cache
# docker-build # build
- name: docker-build - name: build
pull: if-not-exists pull: if-not-exists
image: plugins/docker image: node:14.16.1
volumes: commands:
- name: dockersock - npm run build
path: /var/run/docker.sock when:
settings: event: [push, pull_request]
repo: hub.kaiguawang.cn/longge/visitor-node-api branch: [development, test, master, sso]
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 # docker-build
- name: dev-run - name: docker-build
image: appleboy/drone-ssh pull: if-not-exists
pull: if-not-exists image: plugins/docker
settings: volumes:
host: 172.17.0.1 - name: dockersock
username: root path: /var/run/docker.sock
password: settings:
from_secret: ssh_password repo: hub.kaiguawang.cn/longge/visitor-node-api
port: 22 registry: hub.kaiguawang.cn
command_timeout: 300s tags:
script: - latest
- cd /home/runtime/apps/qunsense - '0.0.1'
- docker compose up -d api username:
when: from_secret: docker_username
event: [push, pull_request] password:
branch: [development] from_secret: docker_password
when:
event: [push, pull_request]
branch: [development, test, master]
- name: notify # run
image: fifsky/drone-wechat-work - name: dev-run
pull: if-not-exists image: appleboy/drone-ssh
# pull: always pull: if-not-exists
settings: settings:
url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4166884e-9d7b-4e7a-a1c8-80d71d4755ba host: 172.17.0.1
msgtype: markdown username: root
content: | password:
{{if eq .Status "success" }} from_secret: ssh_password
#### 🎉 ${DRONE_REPO} 构建成功 port: 22
> Commit: ${DRONE_COMMIT_MESSAGE} command_timeout: 300s
> Author: ${DRONE_COMMIT_AUTHOR} script:
{{else}} - cd /home/runtime/apps/qunsense
#### ❌ ${DRONE_REPO} 构建失败 - docker compose up -d api
> Commit: ${DRONE_COMMIT_MESSAGE} when:
> Author: ${DRONE_COMMIT_AUTHOR} event: [push, pull_request]
> 请立即修复!!! branch: [development]
{{end}}
when:
status:
- failure
- success
- 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

Loading…
Cancel
Save