编程语言/Drone/drone-volume-cache:修订间差异
来自康健生活
| 第116行: | 第116行: | ||
node: | node: | ||
machine1:runner1 | machine1:runner1 | ||
</syntaxhighlight> | |||
<syntaxhighlight lang="yaml"> | |||
pipeline: | |||
# 加载缓存 node_modules | |||
restore-cache: | |||
image: drillster/drone-volume-cache | |||
restore: true | |||
mount: | |||
- ./node_modules | |||
volumes: | |||
- /tmp/cache:/cache | |||
when: | |||
# 触发事件类型[push], [pull_request] | |||
event: [push, pull_request] | |||
# 触发分支 | |||
branch: [devlopment, test, master] | |||
# install | |||
install: | |||
image: node:12-alpine | |||
commands: | |||
# 删除文件 npm install | |||
- rm -rf package-lock.json | |||
- npm --registry https://registry.npm.taobao.org install | |||
when: | |||
event: [push, pull_request] | |||
branch: [devlopment, test, master] | |||
# 更新node_modules缓存 | |||
rebuild-cache: | |||
image: drillster/drone-volume-cache | |||
rebuild: true | |||
mount: | |||
- ./node_modules | |||
volumes: | |||
- /tmp/cache:/cache | |||
when: | |||
event: [push, pull_request] | |||
branch: [devlopment, test, master] | |||
# push | |||
dev-push: | |||
image: appleboy/drone-scp | |||
host: xxx # 可以写到secret中 | |||
port: 22 | |||
username: xxx | |||
password: xxx | |||
target: /app/vue-manage-server | |||
source: . | |||
rm: true | |||
when: | |||
event: [push, pull_request] | |||
branch: [devlopment] | |||
# push | |||
test-push: | |||
image: appleboy/drone-scp | |||
host: xxx # 可以写到secret中 | |||
port: 22 | |||
username: xxx | |||
password: xxx | |||
target: /app/vue-manage-server | |||
source: . | |||
rm: true | |||
when: | |||
event: [push, pull_request] | |||
branch: [test] | |||
# push | |||
master-push: | |||
image: appleboy/drone-scp | |||
host: xxx # 实际应用中,可以写到secret中 | |||
port: 22 | |||
username: xxx | |||
password: xxx | |||
target: /app/vue-manage-server | |||
source: . | |||
rm: true | |||
when: | |||
event: [push, pull_request] | |||
branch: [master] | |||
# run | |||
dev-run: | |||
image: appleboy/drone-ssh | |||
host: xxx | |||
username: xxx | |||
password: xxx | |||
port: 22 | |||
command_timeout: 300s | |||
script: | |||
- cd /app/vue-manage-server | |||
- mkdir seresr | |||
when: | |||
event: [push, pull_request] | |||
branch: [devlopment] | |||
# run | |||
test-run: | |||
image: appleboy/drone-ssh | |||
host: xxx | |||
username: xxx | |||
password: xxx | |||
port: 22 | |||
command_timeout: 300s | |||
script: | |||
- cd /app/vue-manage-server | |||
- mkdir seresr | |||
when: | |||
event: [push, pull_request] | |||
branch: [test] | |||
# run | |||
master-run: | |||
image: appleboy/drone-ssh | |||
host: xxx | |||
username: xxx | |||
password: xxx | |||
port: 22 | |||
command_timeout: 300s | |||
script: | |||
- cd /app/vue-manage-server | |||
- docker build -t vue-manage-server . | |||
- docker run -d -p 4000:4000 vue-manage-server | |||
when: | |||
event: [push, pull_request] | |||
branch: [master] | |||
</syntaxhighlight> | </syntaxhighlight> | ||