2023-08-11 16:39:20 +08:00
|
|
|
# drone 会按顺序执行 pipeline 配置中定义的任务
|
|
|
|
|
|
|
|
# main 分支在 build 和 PR 时执行的 pipeline
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: main-pipeline
|
|
|
|
|
|
|
|
platform:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
|
|
|
|
trigger:
|
|
|
|
branch:
|
|
|
|
include:
|
|
|
|
- main
|
|
|
|
event:
|
|
|
|
include:
|
|
|
|
- custom
|
|
|
|
- push
|
|
|
|
|
|
|
|
clone:
|
|
|
|
disable: true
|
|
|
|
|
|
|
|
steps:
|
2023-12-09 17:35:13 +08:00
|
|
|
- name: build-push-image-and-deploy
|
2023-08-11 16:39:20 +08:00
|
|
|
image: appleboy/drone-ssh
|
|
|
|
settings:
|
|
|
|
host:
|
2023-12-09 17:35:13 +08:00
|
|
|
from_secret: diyue_host
|
2023-08-11 16:39:20 +08:00
|
|
|
username: ubuntu
|
|
|
|
key:
|
2023-12-09 17:35:13 +08:00
|
|
|
from_secret: diyue_key
|
2023-08-11 16:39:20 +08:00
|
|
|
port: 22
|
|
|
|
script_stop: true
|
|
|
|
script:
|
2023-12-09 17:35:13 +08:00
|
|
|
- cd /var/ddk/pzx-web-api
|
2023-08-11 16:39:20 +08:00
|
|
|
- sudo git fetch
|
|
|
|
- sudo git reset --hard ${DRONE_COMMIT}
|
2023-12-09 17:35:13 +08:00
|
|
|
- docker-compose -f docker-compose-build.yml build
|
|
|
|
- source .apiflask.env
|
|
|
|
- echo "$DOCKER_PASSWORD" | docker login $DOCKER_REGISTRY -u $DOCKER_USERNAME --password-stdin
|
|
|
|
- docker push $DOCKER_REGISTRY/bryant/ddk/pzx-web-api:latest
|
|
|
|
- docker stack deploy -c docker-compose-run.yml ddk
|
|
|
|
- docker image prune -f
|