diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..9bc72eb --- /dev/null +++ b/.drone.yml @@ -0,0 +1,58 @@ +# 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: +- name: deploy-k8s-master + image: appleboy/drone-ssh + settings: + host: + from_secret: k8s_master + username: ubuntu + key: + from_secret: k8s_key + port: 22 + script_stop: true + script: + - cd /var/www/pzx-web-api + - sudo git fetch + - sudo git reset --hard ${DRONE_COMMIT} + - sudo docker-compose down + - sudo docker-compose up -d --build --force-recreate + - sudo docker image prune -f +- name: deploy-k8s-worker + image: appleboy/drone-ssh + settings: + host: + from_secret: k8s_worker + username: ubuntu + key: + from_secret: k8s_key + port: 22 + script_stop: true + script: + - cd /var/www/pzx-web-api + - sudo git fetch + - sudo git reset --hard ${DRONE_COMMIT} + - sudo docker-compose down + - sudo docker-compose up -d --build --force-recreate + - sudo docker image prune -f \ No newline at end of file