Files
todo-frontend/.drone.yml
2026-03-20 15:48:10 +00:00

121 lines
2.8 KiB
YAML

kind: pipeline
type: kubernetes
name: build-and-deploy-dev
trigger:
event:
- push
branch:
- dev
steps:
- name: restore-cache
restore_cache:
keys:
- npm-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "package.json" }}
- npm-{{ .Environment.DRONE_REPO_NAME }}-
- name: install
image: node:18-alpine
commands:
- npm install
cache_from:
- npm-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "package.json" }}
- name: build
image: node:18-alpine
commands:
- npm run build:h5
- name: build-image
image: plugins/docker:linux-amd64:linux-amd64
settings:
repo: ccr.ccs.tencentyun.com/violin/todo-frontend
tags:
- ${DRONE_COMMIT_SHA}
- latest
username:
from_secret: registry_username
password:
from_secret: registry_password
- name: deploy-to-k8s
image: bitnami/kubectl:latest
commands:
- kubectl set image deployment/todo-frontend todo-frontend=ccr.ccs.tencentyun.com/violin/todo-frontend:${DRONE_COMMIT_SHA} -n todo-test
- kubectl rollout status deployment/todo-frontend -n todo-test
environment:
KUBECONFIG:
from_secret: kubeconfig
when:
status:
- success
- name: rebuild-cache
rebuild_cache:
keys:
- npm-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "package.json" }}
- npm-{{ .Environment.DRONE_REPO_NAME }}-
---
kind: pipeline
type: kubernetes
name: build-and-deploy-prod
trigger:
event:
- push
branch:
- master
steps:
- name: restore-cache
restore_cache:
keys:
- npm-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "package.json" }}
- npm-{{ .Environment.DRONE_REPO_NAME }}-
- name: install
image: node:18-alpine
commands:
- npm install
cache_from:
- npm-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "package.json" }}
- name: build
image: node:18-alpine
commands:
- npm run build:h5
- name: build-image
image: plugins/docker:linux-amd64:linux-amd64
settings:
repo: ccr.ccs.tencentyun.com/violin/todo-frontend
tags:
- ${DRONE_COMMIT_SHA}
- v1.0.0
username:
from_secret: registry_username
password:
from_secret: registry_password
- name: deploy-to-k8s
image: bitnami/kubectl:latest
commands:
- kubectl set image deployment/todo-frontend todo-frontend=ccr.ccs.tencentyun.com/violin/todo-frontend:${DRONE_COMMIT_SHA} -n todo-prod
- kubectl rollout status deployment/todo-frontend -n todo-prod
environment:
KUBECONFIG:
from_secret: kubeconfig
when:
status:
- success
- name: rebuild-cache
rebuild_cache:
keys:
- npm-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "package.json" }}
- npm-{{ .Environment.DRONE_REPO_NAME }}-