woodpecker/.woodpecker/docs.yml

81 lines
2.2 KiB
YAML
Raw Normal View History

when:
- event: pull_request
- event: push
path: &when_path
- "docs/**"
- ".woodpecker/docs.yml"
# since we generate docs for cli tool we have to watch this too
- "cli/**"
- "cmd/cli/**"
# api docs
- "server/api/**"
branch: ${CI_REPO_DEFAULT_BRANCH}
- cron: update_docs
event: cron
variables:
- &golang_image 'golang:1.20.2'
- &node_image 'node:18-alpine'
steps:
build-cli:
image: *golang_image
commands:
- make docs
when:
- path: *when_path
- event: cron
build:
image: *node_image
directory: docs/
commands:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
when:
- path: *when_path
- event: cron
deploy-preview:
image: woodpeckerci/plugin-surge-preview:next
settings:
path: "docs/build/"
surge_token:
from_secret: SURGE_TOKEN
forge_type: github
forge_url: "https://github.com"
forge_repo_token:
from_secret: GITHUB_TOKEN_SURGE
failure: ignore
when:
event: pull_request
path: *when_path
# TODO: add step to remove preview again after PR is closed (waiting for #286)
deploy:
2023-07-11 21:02:05 +00:00
image: alpine:3.18
secrets:
- BOT_PRIVATE_KEY
commands:
- apk add openssh-client git rsync
- 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
- chmod 0600 $HOME/.ssh/id_rsa
- 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
# 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
- git commit -m "Deploy website - based on ${CI_COMMIT_SHA}"
- git push
when:
event: [push, cron]
path: *when_path