2022-06-14 16:10:00 +08:00
|
|
|
# drone 会自动先拉取代码
|
|
|
|
# 再按顺序执行 pipeline 配置中定义的任务
|
|
|
|
|
2022-06-14 16:12:58 +08:00
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
2023-07-09 02:26:34 +08:00
|
|
|
name: feature
|
2022-06-14 16:12:58 +08:00
|
|
|
|
|
|
|
platform:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
|
2023-07-09 02:26:34 +08:00
|
|
|
trigger:
|
|
|
|
branch:
|
|
|
|
include:
|
|
|
|
- feature/*
|
|
|
|
|
|
|
|
clone:
|
|
|
|
disable: true
|
2022-06-14 16:12:58 +08:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: deploy
|
|
|
|
image: appleboy/drone-ssh
|
|
|
|
settings:
|
2023-07-09 02:26:34 +08:00
|
|
|
host:
|
|
|
|
from_secret: host
|
2022-06-14 16:12:58 +08:00
|
|
|
username: root
|
|
|
|
key:
|
|
|
|
from_secret: ssh_key
|
|
|
|
port: 22
|
|
|
|
script_stop: true
|
|
|
|
script:
|
2023-07-09 02:26:34 +08:00
|
|
|
- cd /var/www/todo
|
|
|
|
- git fetch
|
2023-07-09 02:37:05 +08:00
|
|
|
- git checkout ${DRONE_BRANCH}
|
2023-07-09 02:43:14 +08:00
|
|
|
- git reset --hard ${DRONE_COMMIT}
|
2023-07-09 05:46:44 +08:00
|
|
|
- docker-compose down
|
2023-07-09 05:43:57 +08:00
|
|
|
- docker-compose up -d --build --force-recreate
|
2023-07-09 02:26:34 +08:00
|
|
|
- docker image prune -f
|
|
|
|
when:
|
|
|
|
event:
|
|
|
|
include:
|
|
|
|
- push
|
|
|
|
- custom
|
2022-06-14 16:12:58 +08:00
|
|
|
|
2023-07-09 04:52:38 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: develop
|
|
|
|
|
|
|
|
platform:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
|
|
|
|
trigger:
|
|
|
|
branch:
|
|
|
|
include:
|
|
|
|
- develop
|
|
|
|
|
|
|
|
clone:
|
|
|
|
disable: true
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: deploy
|
|
|
|
image: appleboy/drone-ssh
|
|
|
|
settings:
|
|
|
|
host:
|
|
|
|
from_secret: host
|
|
|
|
username: root
|
|
|
|
key:
|
|
|
|
from_secret: ssh_key
|
|
|
|
port: 22
|
|
|
|
script_stop: true
|
|
|
|
script:
|
|
|
|
- cd /var/www/todo
|
|
|
|
- git fetch
|
|
|
|
- git checkout ${DRONE_BRANCH}
|
|
|
|
- git reset --hard ${DRONE_COMMIT}
|
2023-07-09 05:46:44 +08:00
|
|
|
- docker-compose down
|
2023-07-09 05:43:57 +08:00
|
|
|
- docker-compose up -d --build --force-recreate
|
2023-07-09 05:41:43 +08:00
|
|
|
- docker image prune -f
|
2023-07-09 04:52:38 +08:00
|
|
|
when:
|
|
|
|
event:
|
|
|
|
include:
|
2023-07-09 06:07:17 +08:00
|
|
|
- push
|
2023-07-09 04:52:38 +08:00
|
|
|
|
2022-06-14 16:12:58 +08:00
|
|
|
|
2023-07-09 05:50:21 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: main-pull-request-staging
|
2022-06-14 16:12:58 +08:00
|
|
|
|
2023-07-09 05:50:21 +08:00
|
|
|
platform:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
|
|
|
|
trigger:
|
|
|
|
branch:
|
|
|
|
include:
|
|
|
|
- main
|
2023-07-09 06:37:46 +08:00
|
|
|
event:
|
|
|
|
- pull_request
|
|
|
|
action:
|
|
|
|
include:
|
|
|
|
- opened
|
|
|
|
- reopened
|
|
|
|
- synchronized
|
2023-07-09 05:50:21 +08:00
|
|
|
|
|
|
|
clone:
|
|
|
|
disable: true
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: deploy
|
|
|
|
image: appleboy/drone-ssh
|
|
|
|
settings:
|
|
|
|
host:
|
|
|
|
from_secret: host
|
|
|
|
username: root
|
|
|
|
key:
|
|
|
|
from_secret: ssh_key
|
|
|
|
port: 22
|
|
|
|
script_stop: true
|
|
|
|
script:
|
|
|
|
- cd /var/www/todo
|
|
|
|
- git fetch
|
|
|
|
- git checkout ${DRONE_BRANCH}
|
|
|
|
- git reset --hard ${DRONE_COMMIT}
|
|
|
|
- docker-compose down
|
|
|
|
- docker-compose up -d --build --force-recreate
|
|
|
|
- docker image prune -f
|
2023-07-09 06:00:39 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
2023-07-10 12:54:22 +08:00
|
|
|
name: main-tag-prod
|
2023-07-09 06:00:39 +08:00
|
|
|
|
|
|
|
platform:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
|
|
|
|
trigger:
|
|
|
|
branch:
|
|
|
|
include:
|
|
|
|
- main
|
|
|
|
event:
|
|
|
|
include:
|
2023-07-10 12:54:22 +08:00
|
|
|
- tag
|
2023-07-09 06:00:39 +08:00
|
|
|
|
|
|
|
clone:
|
|
|
|
disable: true
|
|
|
|
|
|
|
|
steps:
|
2023-07-10 12:54:22 +08:00
|
|
|
- name: clone-repo
|
|
|
|
image: alpine/git
|
|
|
|
commands:
|
|
|
|
- git clone ${DRONE_GIT_HTTP_URL} .
|
|
|
|
- git checkout ${DRONE_BRANCH}
|
|
|
|
- name: build-and-push-image
|
|
|
|
image: plugins/docker
|
|
|
|
settings:
|
|
|
|
registry:
|
|
|
|
from_secret: Œ
|
|
|
|
username:
|
|
|
|
from_secret: docker_username
|
|
|
|
password:
|
|
|
|
from_secret: docker_password
|
|
|
|
repo: gitea.bearcatlog.com/bryant/todo
|
|
|
|
context: .
|
|
|
|
dockerfile: ./Dockerfile
|
|
|
|
tags:
|
|
|
|
- ${DRONE_TAG}
|
|
|
|
# auto_tag: true
|
|
|
|
purge: true
|
|
|
|
compress: true
|
|
|
|
# TODO 通知 k8s 更新镜像
|