2023-07-12 21:25:05 +00:00
|
|
|
when:
|
2023-08-07 11:03:23 +00:00
|
|
|
- event: pull_request
|
|
|
|
- event: push
|
|
|
|
path: &when_path
|
2023-10-24 12:42:05 +00:00
|
|
|
- 'docs/**'
|
|
|
|
- '.woodpecker/docs.yml'
|
2023-08-07 09:14:30 +00:00
|
|
|
# since we generate docs for cli tool we have to watch this too
|
2023-10-24 12:42:05 +00:00
|
|
|
- 'cli/**'
|
|
|
|
- 'cmd/cli/**'
|
2023-08-07 09:14:30 +00:00
|
|
|
# api docs
|
2023-10-24 12:42:05 +00:00
|
|
|
- 'server/api/**'
|
2023-08-07 11:03:23 +00:00
|
|
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
2023-08-07 09:14:30 +00:00
|
|
|
- cron: update_docs
|
|
|
|
event: cron
|
2022-08-14 07:19:24 +00:00
|
|
|
|
2023-08-07 08:58:42 +00:00
|
|
|
variables:
|
2023-10-11 09:11:48 +00:00
|
|
|
- &golang_image 'golang:1.21.3'
|
2023-10-22 06:10:42 +00:00
|
|
|
- &node_image 'node:21-alpine'
|
2023-08-07 08:58:42 +00:00
|
|
|
|
2023-06-30 11:32:17 +00:00
|
|
|
steps:
|
2022-09-25 12:36:31 +00:00
|
|
|
build-cli:
|
2022-09-27 20:19:39 +00:00
|
|
|
image: *golang_image
|
2022-09-25 12:36:31 +00:00
|
|
|
commands:
|
|
|
|
- make docs
|
2023-08-07 11:03:23 +00:00
|
|
|
when:
|
|
|
|
- path: *when_path
|
|
|
|
- event: cron
|
2022-09-25 12:36:31 +00:00
|
|
|
|
2021-09-23 15:54:19 +00:00
|
|
|
build:
|
2022-08-14 07:19:24 +00:00
|
|
|
image: *node_image
|
2022-10-25 12:51:29 +00:00
|
|
|
directory: docs/
|
2021-09-23 15:54:19 +00:00
|
|
|
commands:
|
2022-10-08 14:15:07 +00:00
|
|
|
- corepack enable
|
|
|
|
- pnpm install --frozen-lockfile
|
|
|
|
- pnpm build
|
2023-08-07 11:03:23 +00:00
|
|
|
when:
|
|
|
|
- path: *when_path
|
|
|
|
- event: cron
|
2022-03-23 09:31:12 +00:00
|
|
|
|
|
|
|
deploy-preview:
|
2023-10-17 05:36:27 +00:00
|
|
|
image: woodpeckerci/plugin-surge-preview:1.2.2
|
2022-03-23 09:31:12 +00:00
|
|
|
settings:
|
2023-10-24 12:42:05 +00:00
|
|
|
path: 'docs/build/'
|
2022-03-23 09:31:12 +00:00
|
|
|
surge_token:
|
|
|
|
from_secret: SURGE_TOKEN
|
|
|
|
forge_type: github
|
2023-10-24 12:42:05 +00:00
|
|
|
forge_url: 'https://github.com'
|
2022-03-23 09:31:12 +00:00
|
|
|
forge_repo_token:
|
|
|
|
from_secret: GITHUB_TOKEN_SURGE
|
2023-07-25 10:41:58 +00:00
|
|
|
failure: ignore
|
2022-03-23 09:31:12 +00:00
|
|
|
when:
|
|
|
|
event: pull_request
|
2023-08-07 11:03:23 +00:00
|
|
|
path: *when_path
|
2022-08-14 07:19:24 +00:00
|
|
|
|
2022-03-23 09:31:12 +00:00
|
|
|
# TODO: add step to remove preview again after PR is closed (waiting for #286)
|
2021-09-23 15:54:19 +00:00
|
|
|
|
|
|
|
deploy:
|
2023-07-11 21:02:05 +00:00
|
|
|
image: alpine:3.18
|
2021-09-11 15:10:32 +00:00
|
|
|
secrets:
|
|
|
|
- BOT_PRIVATE_KEY
|
|
|
|
commands:
|
2021-09-23 15:54:19 +00:00
|
|
|
- apk add openssh-client git rsync
|
2021-09-11 15:10:32 +00:00
|
|
|
- mkdir -p $HOME/.ssh
|
|
|
|
- ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts
|
2021-09-11 15:16:26 +00:00
|
|
|
- echo "$BOT_PRIVATE_KEY" > $HOME/.ssh/id_rsa
|
2021-09-11 15:10:32 +00:00
|
|
|
- chmod 0600 $HOME/.ssh/id_rsa
|
2021-09-11 16:48:52 +00:00
|
|
|
- git config --global user.email "woodpecker-bot@obermui.de"
|
|
|
|
- git config --global user.name "woodpecker-bot"
|
2023-07-12 20:00:52 +00:00
|
|
|
- git clone --depth 1 --single-branch git@github.com:woodpecker-ci/woodpecker-ci.github.io.git /repo
|
2021-09-23 15:54:19 +00:00
|
|
|
# copy all docs files and delete all old ones, but leave CNAME and index.yaml untouched
|
|
|
|
- rsync -r --exclude .git --exclude CNAME --exclude index.yaml --exclude README.md --delete docs/build/ /repo
|
|
|
|
- cd /repo
|
|
|
|
- git add .
|
|
|
|
# exit successfully if nothing changed
|
|
|
|
- test -n "$(git status --porcelain)" || exit 0
|
2021-11-25 19:43:31 +00:00
|
|
|
- git commit -m "Deploy website - based on ${CI_COMMIT_SHA}"
|
2021-09-23 15:54:19 +00:00
|
|
|
- git push
|
2021-09-11 15:10:32 +00:00
|
|
|
when:
|
2023-08-07 11:03:23 +00:00
|
|
|
event: [push, cron]
|
|
|
|
path: *when_path
|