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