diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..fcf33e3 --- /dev/null +++ b/.drone.yml @@ -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 =====" diff --git a/README.md b/README.md index fae492b..4acf240 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +## 介绍 + +学习过的知识的笔记总结, 使用 vitepress 构建, 会经常更新, 支持 docker 一键部署 + ## 关于作者 一个前端开发工程师, 目前居于深圳 ♪(^∀^●)ノシ (●´∀`)♪