ToyBoomServer/.drone.yml
2024-09-02 18:07:30 +00:00

147 lines
4.0 KiB
YAML

kind: pipeline
name: build-and-publish
steps:
- name: download modules
image: git.vaala.cloud/vaalacat/golang:1.21-alpine
commands:
- sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
- apk update --no-cache && apk add --no-cache tzdata git
- CGO_ENABLED=0 GOPRIVATE=git.vaala.cloud GOPROXY=https://goproxy.cn,https://proxy.golang.org,direct go mod download
- mkdir -p etc
- cp /etc/ssl/certs/ca-certificates.crt ./etc/ca-certificates.crt
- cp /usr/share/zoneinfo/Asia/Shanghai ./etc/Shanghai
volumes:
- name: gocache
path: /go/pkg/mod
- name: build
path: /tmp/app
when:
event:
- pull_request
- promote
- rollback
- name: build frontend
image: git.vaala.cloud/vaalacat/node:20-alpine
commands:
- sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
- apk update --no-cache && apk add --no-cache tzdata git openssh curl
- mkdir -p ~/.ssh
- npm install -g pnpm
- ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
- corepack enable
- corepack prepare pnpm@latest-7 --activate
- pnpm config set store-dir /root/.pnpm-store
- pnpm install --no-frozen-lockfile
- pnpm build
# - curl -sSf https://sshx.io/get | sh
# - sshx
# - yarn install
# - yarn run build
volumes:
- name: nodecache
path: /root/.pnpm-store
when:
event:
- pull_request
- promote
- rollback
- name: build - amd64
image: git.vaala.cloud/vaalacat/golang:1.21-alpine
commands:
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOPRIVATE=git.vaala.cloud GOPROXY=https://goproxy.cn,https://proxy.golang.org,direct go build -ldflags="-s -w" -o toyboom-server-amd64 cmd/*.go
volumes:
- name: gocache
path: /go/pkg/mod
- name: build
path: /tmp/app
depends_on:
- build frontend
- download modules
when:
event:
- pull_request
- promote
- rollback
- name: build - arm64
image: git.vaala.cloud/vaalacat/golang:1.21-alpine
commands:
- CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOPRIVATE=git.vaala.cloud GOPROXY=https://goproxy.cn,https://proxy.golang.org,direct go build -ldflags="-s -w" -o toyboom-server-arm64 cmd/*.go
volumes:
- name: gocache
path: /go/pkg/mod
- name: build
path: /tmp/app
depends_on:
- build frontend
- download modules
when:
event:
- pull_request
- promote
- rollback
- name: publish - amd64
image: git.vaala.cloud/vaalacat/drone-docker-buildx:24
privileged: true
settings:
debug: false
platforms:
- linux/amd64
build_args:
- ARCH=amd64
repo: git.vaala.cloud/sharkai/toyboom-server
tags:
- amd64-c3e691e3
registry:
from_secret: DOCKER_REGISTRY
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
depends_on:
- build - amd64
when:
event:
- promote
- rollback
target:
- production
- name: publish - arm64
image: git.vaala.cloud/vaalacat/drone-docker-buildx:24
privileged: true
settings:
debug: false
platforms:
- linux/arm64
build_args:
- ARCH=arm64
repo: git.vaala.cloud/sharkai/toyboom-server
tags:
- arm64-c3e691e3
registry:
from_secret: DOCKER_REGISTRY
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
depends_on:
- build - arm64
when:
event:
- promote
- rollback
target:
- production
volumes:
- name: build
temp: {}
- name: gocache
host:
path: /tmp/drone/github.com/nose7en/ToyBoomServer/gocache
- name: nodecache
host:
path: /tmp/drone/github.com/nose7en/ToyBoomServer/nodecache