drone无人机-当前站点的发布实践

drone无人机-当前站点的发布实践

简介

看起来还有很多改进的空间, 但是我后来发现了 gitea-runner 这一套了, 就不再想用 drone 了。
回头看我还是很喜欢的 drone 的纯容器模式。使用 runner 不得不接触大量的 js,虽然不复杂,但也挺麻烦的。

.drone.yml 文件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
kind: pipeline
type: kubernetes
name: myblog
service_account_name: drone

# 因为有个性化的 git 需求, 所以这里禁用默认的 clone
clone:
  disable: true

# 触发器
trigger:
  event:
    - push

steps:

- name: 克隆仓库
  image: registry.services.wait/cwx/drone/git
  pull: if-not-exists
  settings:
    depth: 1
    skip_verify: true
    tags: true

  environment:
    GITEA_TOKEN:
      from_secret: git_token
  commands:
    - git config --global http.sslVerify false
    - git clone https://chenwx:$GITEA_TOKEN@git.services.wait/chenwx/myblog.git .
    - git clone https://chenwx:$GITEA_TOKEN@git.services.wait/chenwx/hugo-theme-stack.git themes/hugo-theme-stack

- name: 编译
  image: registry.services.wait/cwx/hugo:ubuntu-v0.118
  pull: if-not-exists
  depends_on: [克隆仓库]
  commands:
    - hugo
    - tar zcvf myblog.tar.gz -C public/ .


- name: 推送
  image: registry.services.wait/cwx/drone/appleboy/drone-scp
  pull: if-not-exists
  depends_on: [ 编译 ]
  settings:
    host: 10.2.1.5
    username: wait
    key:
      from_secret: wait_ssh_key
    port: 22
    source: myblog.tar.gz
    target: /tmp/


- name: deplay
  image: registry.services.wait/cwx/drone/appleboy/drone-ssh
  pull: if-not-exists
  depends_on: [ 推送 ]
  settings:
    host:
      - 10.2.1.5
    username: wait
    key:
      from_secret: wait_ssh_key
    port: 22
    command_timeout: 1m
    script:
      - rm -rf /data/nfs_private/blog-web-data/blog/*
      - tar xf /tmp/myblog.tar.gz -C /data/nfs_private/blog-web-data/blog/
      - rm -f /tmp/myblog.tar.gz
Licensed under CC BY-NC-SA 4.0
转载或引用本文时请遵守许可协议,知会作者并注明出处
不得用于商业用途!
最后更新于 2023-08-09 00:00 UTC