a5748a3e2b
GitLab masked variables reject values with whitespace (like SSH keys), so store the key as base64 and decode it in the pipeline.
38 lines
823 B
YAML
38 lines
823 B
YAML
workflow:
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == "main"
|
|
|
|
stages:
|
|
- build
|
|
- deploy
|
|
|
|
build:
|
|
stage: build
|
|
image: node:24.15-trixie-slim
|
|
before_script:
|
|
- corepack enable
|
|
- corepack prepare pnpm@latest --activate
|
|
- pnpm config set store-dir .pnpm-store
|
|
script:
|
|
- pnpm install --frozen-lockfile
|
|
- pnpm build
|
|
artifacts:
|
|
paths:
|
|
- doc_build/
|
|
|
|
deploy:
|
|
stage: deploy
|
|
image: alpine:latest
|
|
needs:
|
|
- build
|
|
before_script:
|
|
- apk add --no-cache openssh-client rsync
|
|
- mkdir -p ~/.ssh
|
|
- echo "$SSH_PRIVATE_KEY_BASE64" | base64 -d > ~/.ssh/id_ed25519
|
|
- chmod 600 ~/.ssh/id_ed25519
|
|
- ssh-keyscan -H onixbyte.cn >> ~/.ssh/known_hosts
|
|
script:
|
|
- rsync -avz --delete doc_build/ ${SSH_USER}@onixbyte.cn:${DEPLOY_PATH}
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == "main"
|