2024-01-03 09:31:48 +00:00
|
|
|
variables:
|
2024-10-05 09:32:30 +00:00
|
|
|
- &golang_image 'docker.io/golang:1.23'
|
2024-10-20 09:19:18 +00:00
|
|
|
- &node_image 'docker.io/node:23-alpine'
|
2024-12-07 02:07:45 +00:00
|
|
|
- &alpine_image 'docker.io/alpine:3.21'
|
2024-01-03 09:31:48 +00:00
|
|
|
- path: &when_path
|
2023-10-24 12:42:05 +00:00
|
|
|
- 'docs/**'
|
2024-01-11 17:43:54 +00:00
|
|
|
- '.woodpecker/docs.yaml'
|
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/**'
|
2024-01-03 09:31:48 +00:00
|
|
|
- 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
|
2023-11-11 20:35:48 +00:00
|
|
|
branch:
|
|
|
|
- ${CI_REPO_DEFAULT_BRANCH}
|
2023-12-29 12:19:46 +00:00
|
|
|
- event: pull_request_closed
|
|
|
|
path: *when_path
|
2023-11-11 08:03:52 +00:00
|
|
|
- event: manual
|
|
|
|
evaluate: 'TASK == "docs"'
|
2022-08-14 07:19:24 +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
|
2024-01-10 14:10:56 +00:00
|
|
|
event: [tag, pull_request, push]
|
2024-01-03 09:31:48 +00:00
|
|
|
- event: manual
|
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
|
2024-01-10 14:10:56 +00:00
|
|
|
event: [tag, pull_request, push]
|
2024-01-03 09:31:48 +00:00
|
|
|
- event: manual
|
2022-03-23 09:31:12 +00:00
|
|
|
|
|
|
|
deploy-preview:
|
2024-12-01 02:16:08 +00:00
|
|
|
image: docker.io/woodpeckerci/plugin-surge-preview:1.3.3
|
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_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:
|
2023-12-29 12:19:46 +00:00
|
|
|
event: [pull_request, pull_request_closed]
|
2023-08-07 11:03:23 +00:00
|
|
|
path: *when_path
|
2022-08-14 07:19:24 +00:00
|
|
|
|
2024-01-03 09:31:48 +00:00
|
|
|
deploy-prepare:
|
|
|
|
image: *alpine_image
|
2024-11-13 13:30:14 +00:00
|
|
|
environment:
|
|
|
|
BOT_PRIVATE_KEY:
|
|
|
|
from_secret: BOT_PRIVATE_KEY
|
2024-01-03 09:31:48 +00:00
|
|
|
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 git@github.com: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}
|
|
|
|
|
2024-01-03 17:33:31 +00:00
|
|
|
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
|
2024-01-03 09:31:48 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-09-23 15:54:19 +00:00
|
|
|
deploy:
|
2024-01-03 09:31:48 +00:00
|
|
|
image: *alpine_image
|
2024-11-13 13:30:14 +00:00
|
|
|
environment:
|
|
|
|
BOT_PRIVATE_KEY:
|
|
|
|
from_secret: BOT_PRIVATE_KEY
|
2021-09-11 15:10:32 +00:00
|
|
|
commands:
|
2024-01-03 09:31:48 +00:00
|
|
|
- apk add openssh-client rsync git
|
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
|
2024-01-03 17:33:31 +00:00
|
|
|
- git config --global user.email "woodpecker-bot@obermui.de"
|
|
|
|
- git config --global user.name "woodpecker-bot"
|
2024-01-03 09:31:48 +00:00
|
|
|
- cd ./docs_repo
|
2021-09-23 15:54:19 +00:00
|
|
|
- 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-11-11 08:03:52 +00:00
|
|
|
- event: push
|
2024-01-03 09:31:48 +00:00
|
|
|
path:
|
|
|
|
- <<: *when_path
|
|
|
|
- <<: *docker_path
|
2023-11-29 13:17:49 +00:00
|
|
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
2024-01-03 09:31:48 +00:00
|
|
|
- event: [manual, tag]
|