# drone 会自动先拉取代码 # 再按顺序执行 pipeline 配置中定义的任务 kind: pipeline type: docker name: feature platform: os: linux arch: amd64 trigger: branch: include: - feature/* event: include: - push - custom 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 --- kind: pipeline type: docker name: develop platform: os: linux arch: amd64 trigger: branch: include: - develop event: include: - push 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 --- kind: pipeline type: docker name: main-pull-request-staging platform: os: linux arch: amd64 trigger: branch: include: - main event: - pull_request action: include: - opened - reopened - synchronized 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 --- kind: pipeline type: docker name: main-tag-prod platform: os: linux arch: amd64 trigger: event: include: - tag clone: disable: true steps: - 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: docker_registry username: from_secret: docker_username password: from_secret: docker_password repo: gitea.bearcatlog.com/bryant/todo context: . dockerfile: ./Dockerfile tags: - ${DRONE_TAG} purge: true compress: true # TODO 通知 k8s 更新镜像