-
-
Notifications
You must be signed in to change notification settings - Fork 393
/
Copy pathdocs.yaml
153 lines (144 loc) · 4.35 KB
/
docs.yaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
variables:
- &golang_image 'docker.io/golang:1.23'
- &node_image 'docker.io/node:23-alpine'
- &alpine_image 'docker.io/alpine:3.21'
- path: &when_path
- 'docs/**'
- '.woodpecker/docs.yaml'
# since we generate docs for cli tool we have to watch this too
- 'cli/**'
- 'cmd/cli/**'
# api docs
- 'server/api/**'
- path: &docker_path # web source code
- 'web/**'
# api source code
- 'server/api/**'
# go source code
- '**/*.go'
- 'go.*'
# schema changes
- 'pipeline/schema/**'
# Dockerfile changes
- 'docker/**'
when:
- event: tag
- event: pull_request
- event: push
path:
- <<: *when_path
- <<: *docker_path
branch:
- ${CI_REPO_DEFAULT_BRANCH}
- event: pull_request_closed
path: *when_path
- event: manual
evaluate: 'TASK == "docs"'
steps:
build-cli:
image: *golang_image
commands:
- make docs
when:
- path: *when_path
event: [tag, pull_request, push]
- event: manual
build:
image: *node_image
directory: docs/
commands:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
when:
- path: *when_path
event: [tag, pull_request, push]
- event: manual
deploy-preview:
image: docker.io/woodpeckerci/plugin-surge-preview:1.3.3
settings:
path: 'docs/build/'
surge_token:
from_secret: SURGE_TOKEN
forge_repo_token:
from_secret: GITHUB_TOKEN_SURGE
failure: ignore
when:
event: [pull_request, pull_request_closed]
path: *when_path
deploy-prepare:
image: *alpine_image
environment:
BOT_PRIVATE_KEY:
from_secret: BOT_PRIVATE_KEY
commands:
- apk add openssh-client git
- mkdir -p $HOME/.ssh
- ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts
- echo "$BOT_PRIVATE_KEY" > $HOME/.ssh/id_rsa
- chmod 0600 $HOME/.ssh/id_rsa
- git clone --depth 1 --single-branch [email protected]:woodpecker-ci/woodpecker-ci.github.io.git ./docs_repo
when:
- event: push
path:
- <<: *when_path
- <<: *docker_path
branch: ${CI_REPO_DEFAULT_BRANCH}
- event: [manual, tag]
# update latest and next version
version-next:
image: *alpine_image
commands:
- apk add jq
- jq '.next = "next-${CI_COMMIT_SHA:0:10}"' ./docs_repo/version.json > ./docs_repo/version.json.tmp
- mv ./docs_repo/version.json.tmp ./docs_repo/version.json
when:
- event: push
path: *docker_path
branch: ${CI_REPO_DEFAULT_BRANCH}
version-release:
image: *alpine_image
commands:
- apk add jq
- if [[ "${CI_COMMIT_TAG}" != *"rc"* ]] ; then jq '.latest = "${CI_COMMIT_TAG}"' ./docs_repo/version.json > ./docs_repo/version.json.tmp && mv ./docs_repo/version.json.tmp ./docs_repo/version.json ; fi
- jq '.rc = "${CI_COMMIT_TAG}"' ./docs_repo/version.json > ./docs_repo/version.json.tmp
- mv ./docs_repo/version.json.tmp ./docs_repo/version.json
when:
- event: tag
copy-files:
image: *alpine_image
commands:
- apk add rsync
# copy all docs files and delete all old ones, but leave CNAME, index.yaml and version.json untouched
- rsync -r --exclude .git --exclude CNAME --exclude index.yaml --exclude README.md --exclude version.json --delete docs/build/ ./docs_repo
when:
- event: push
path: *when_path
branch: ${CI_REPO_DEFAULT_BRANCH}
- event: manual
deploy:
image: *alpine_image
environment:
BOT_PRIVATE_KEY:
from_secret: BOT_PRIVATE_KEY
commands:
- apk add openssh-client rsync git
- mkdir -p $HOME/.ssh
- ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts
- echo "$BOT_PRIVATE_KEY" > $HOME/.ssh/id_rsa
- chmod 0600 $HOME/.ssh/id_rsa
- git config --global user.email "[email protected]"
- git config --global user.name "woodpecker-bot"
- cd ./docs_repo
- git add .
# exit successfully if nothing changed
- test -n "$(git status --porcelain)" || exit 0
- git commit -m "Deploy website - based on ${CI_COMMIT_SHA}"
- git push
when:
- event: push
path:
- <<: *when_path
- <<: *docker_path
branch: ${CI_REPO_DEFAULT_BRANCH}
- event: [manual, tag]