Skip to content

Commit

Permalink
feat: 增加了 drone cicd 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
liaohui5 committed Dec 15, 2023
1 parent 032c2e9 commit 53fe315
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
kind: pipeline
type: docker
name: deploy

# push 代码的时候就触发这个流水线
trigger:
event:
- push

# 定义缓存目录(放到宿主机的 /tmp/drone_cache 目录下)
volumes:
- name: cache
host:
path: /tmp/drone_cache

steps:
# 使用缓存(如果有的话)
- name: restore-cache
image: drillster/drone-volume-cache
pull: if-not-exists
volumes:
- name: cache
path: /cache
settings:
restore: true
mount:
- ./node_modules

# 安装依赖 编译源码 压缩打包
- name: build-and-compress-source-code
image: node:lts-alpine
pull: if-not-exists
commands:
- npm config set registry https://registry.npm.taobao.org
- npm install -g pnpm
- pnpm install --no-frozen-lockfile
- pnpm docs:build
- ls -al
- mv ./docs/.vitepress/dist ./dist
- tar -cjvf dist.bz2 ./dist
- echo "===== build completed ====="

# 制作缓存(需要指定缓存目录, 不要每次去下载 node_modules)
- name: rebuild-cache
image: drillster/drone-volume-cache
pull: if-not-exists
volumes:
- name: cache
path: /cache
settings:
rebuild: true
restore: false
mount:
- ./node_modules

# 将文件上传到服务器
- name: upload-file-to-server
image: appleboy/drone-scp
pull: if-not-exists
when:
branch: main # 只有在 push 到 main 分支才执行
settings:
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
password:
from_secret: ssh_pass
port:
from_secret: ssh_port
command_timeout: 2m
source: ./dist.bz2
target: ~/gitea/study_notes

# 连接上服务器然后执行一些脚本
- name: deploy-to-server
image: appleboy/drone-ssh
pull: if-not-exists
when:
branch: main # 只有在push 到 main 分支的时候才执行
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
password:
from_secret: ssh_pass
port:
from_secret: ssh_port
command_timeout: 2m
script:
- cd ~/gitea/study_notes
- rm -rf ./dist
- tar -xjvf ./dist.bz2
- rm -rf ./dist.bz2
- ls -al
- echo "===== deploy completed ====="
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 介绍

学习过的知识的笔记总结, 使用 vitepress 构建, 会经常更新, 支持 docker 一键部署

## 关于作者

一个前端开发工程师, 目前居于深圳 ♪(^∀^●)ノシ (●´∀`)♪
Expand Down

0 comments on commit 53fe315

Please sign in to comment.