kind: pipeline type: docker name: isle-website steps: # 恢复缓存 - name: restore-cache pull: if-not-exists # 镜像不存在则拉取,避免多次下载 image: drillster/drone-volume-cache volumes: - name: cache path: /cache settings: restore: true mount: - ./node_modules # 安装依赖 - name: install pull: if-not-exists image: node:16.17.1 commands: - echo "安装依赖" - echo "全局安装PNPM" - npm config set registry https://registry.npmmirror.com/ - npm install -g pnpm@8.15.5 - pnpm -v - echo "PNPM安装完成" - pnpm config get registry - pnpm config set registry https://registry.npmmirror.com/ # - pnpm config set registry http://registry.npm.taobao.org/ # - pnpm config set registry https://registry.npmjs.org - pnpm install --no-frozen-lockfile # 构建 - name: build pull: if-not-exists image: node:16.17.1 commands: - echo "开始构建" - npm config set registry https://registry.npmmirror.com/ - npm install -g pnpm@8.15.5 - pnpm docs:build - ls # 更新缓存 - name: rebuild-cache pull: if-not-exists image: drillster/drone-volume-cache volumes: - name: cache path: /cache settings: rebuild: true mount: - ./node_modules # 上传 - name: upload image: appleboy/drone-scp settings: host: from_secret: ssh_host username: from_secret: ssh_username password: from_secret: ssh_password target: /srv/nginx/html/isle/website source: ./.vitepress/dist/* strip_components: 2 - name: deploy pull: if-not-exists image: appleboy/drone-ssh settings: host: from_secret: ssh_host username: from_secret: ssh_username password: from_secret: ssh_password port: 22 script: - echo "SSH已连接,开始部署" - cd /srv/nginx - pwd # - docker restart nginx # - cp -r /drone/src/dist/* web - echo "部署完成" # 通知 - name: notify pull: if-not-exists image: drillster/drone-email settings: recipients_only: true # 只发送给指定邮件收件人,不默认发送给流水线创建人 host: smtp.feishu.cn # SMTP服务器 例如 smtp.qq.com port: 587 # SMTP服务端口 例如QQ邮箱端口465 username: from_secret: mail_username password: from_secret: mail_password from: from_secret: mail_username recipients: - lijianchao@sentenceend.com # - biankunchao@sentenceend.com subject: Drone CI Build or Deployment(${DRONE_REPO}) body: |- 仓库 ${DRONE_REPO} 在 ${DRONE_BRANCH} 分支触发了 ${DRONE_BUILD_EVENT} 事件,提交信息 ${DRONE_COMMIT_MESSAGE} ,构建和发布 ${DRONE_BUILD_STATUS}! # 挂载本地磁盘路径 volumes: - name: cache host: path: /tmp/drone-cache trigger: branch: - main event: - push