From 186d639ce27c5edef0590c451823cfa65084a9cc Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 02:34:26 +0800 Subject: [PATCH 01/15] fix drone config --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3977763..0ef5cea 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,5 @@ # drone 会自动先拉取代码 # 再按顺序执行 pipeline 配置中定义的任务 ---- kind: pipeline type: docker -- 2.40.1 From 664d7aa60d9ae62a360b88af95b297b92c67bea2 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 02:37:05 +0800 Subject: [PATCH 02/15] fix drone config --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 0ef5cea..a499649 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,6 +32,7 @@ steps: - cd /var/www/todo - git fetch - git reset --hard ${DRONE_COMMIT} + - git checkout ${DRONE_BRANCH} - docker-compose down - docker-compose up -d --build - docker image prune -f -- 2.40.1 From 86eaff16b0ab38926558a1cb9cc7766fb84067d1 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 02:43:14 +0800 Subject: [PATCH 03/15] fix drone config --- .drone.yml | 2 +- Dockerfile | 4 ++-- docker-compose.yml | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index a499649..01eb176 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,8 +31,8 @@ steps: script: - cd /var/www/todo - git fetch - - git reset --hard ${DRONE_COMMIT} - git checkout ${DRONE_BRANCH} + - git reset --hard ${DRONE_COMMIT} - docker-compose down - docker-compose up -d --build - docker image prune -f diff --git a/Dockerfile b/Dockerfile index d567e17..f2187d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.11 -WORKDIR /app +#WORKDIR /app -CMD ["python3", "test.py"] \ No newline at end of file +# CMD ["python3", "test.py"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 094c8b2..092d07f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,4 +12,6 @@ services: environment: TZ: "Asia/Shanghai" tty: true + working_dir: /app + command: ["python3", "test.py"] -- 2.40.1 From e198e15699da0fd3fbff8232e2987cce83ea99a8 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 04:52:38 +0800 Subject: [PATCH 04/15] fix drone config --- .drone.yml | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/.drone.yml b/.drone.yml index 01eb176..296aa10 100644 --- a/.drone.yml +++ b/.drone.yml @@ -42,5 +42,92 @@ steps: - push - custom +--- + +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} + - docker-compose down + - docker-compose up -d --build + - docker image prune -f + when: + event: + include: + - pull_request + action: + include: + - opened + - reopened + - synchronized +- name: gitea-pr-comment-failure + image: tsakidev/giteacomment:latest + settings: + gitea_token: + from_secret: gitea_token + gitea_base_url: + from_secret: gitea_base_url + comment_title: "部署 sit 环境失败" + comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境失败" + when: + status: + - failure + event: + include: + - pull_request + action: + include: + - opened + - reopened + - synchronized +- name: gitea-pr-comment-success + image: tsakidev/giteacomment:latest + settings: + gitea_token: + from_secret: gitea_token + gitea_base_url: + from_secret: gitea_base_url + comment_title: "部署 sit 环境成功" + comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境成功" + when: + status: + - success + event: + include: + - pull_request + action: + include: + - opened + - reopened + - synchronized + -- 2.40.1 From 8e0d7d13de93f1e24bb294a3f45ebf78417e1431 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:01:53 +0800 Subject: [PATCH 05/15] fix drone config 2 --- .drone.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 296aa10..4d77f53 100644 --- a/.drone.yml +++ b/.drone.yml @@ -93,8 +93,7 @@ steps: settings: gitea_token: from_secret: gitea_token - gitea_base_url: - from_secret: gitea_base_url + gitea_base_url: https://gitea.bearcatlog.com comment_title: "部署 sit 环境失败" comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境失败" when: @@ -113,8 +112,7 @@ steps: settings: gitea_token: from_secret: gitea_token - gitea_base_url: - from_secret: gitea_base_url + gitea_base_url: https://gitea.bearcatlog.com comment_title: "部署 sit 环境成功" comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境成功" when: -- 2.40.1 From acf13bb6b85973ee0e7aa5d0195745f568c83ecd Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:08:35 +0800 Subject: [PATCH 06/15] fix drone config 3 --- .drone.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4d77f53..4670a0b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -77,7 +77,7 @@ steps: - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - docker-compose down - - docker-compose up -d --build + - docker-compose up -d --build --force-recreate - docker image prune -f when: event: @@ -93,7 +93,8 @@ steps: settings: gitea_token: from_secret: gitea_token - gitea_base_url: https://gitea.bearcatlog.com + gitea_base_url: + from_secret: gitea_base_url comment_title: "部署 sit 环境失败" comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境失败" when: @@ -112,7 +113,8 @@ steps: settings: gitea_token: from_secret: gitea_token - gitea_base_url: https://gitea.bearcatlog.com + gitea_base_url: + from_secret: gitea_base_url comment_title: "部署 sit 环境成功" comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境成功" when: -- 2.40.1 From 530d52fdddf740f7c9f3a076d9a41dc970c325fa Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:12:10 +0800 Subject: [PATCH 07/15] fix drone config 4 --- .drone.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4670a0b..81cf4d6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -34,7 +34,7 @@ steps: - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - docker-compose down - - docker-compose up -d --build + - docker-compose up -d --build --force-recreate - docker image prune -f when: event: @@ -95,7 +95,6 @@ steps: from_secret: gitea_token gitea_base_url: from_secret: gitea_base_url - comment_title: "部署 sit 环境失败" comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境失败" when: status: @@ -115,7 +114,6 @@ steps: from_secret: gitea_token gitea_base_url: from_secret: gitea_base_url - comment_title: "部署 sit 环境成功" comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境成功" when: status: -- 2.40.1 From 6fa57028dd05d004e6a8b40e5abafbc8626e7024 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:26:52 +0800 Subject: [PATCH 08/15] fix drone config 5 --- .drone.yml | 4 ++-- docker-compose.yml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 81cf4d6..e5b9722 100644 --- a/.drone.yml +++ b/.drone.yml @@ -89,7 +89,7 @@ steps: - reopened - synchronized - name: gitea-pr-comment-failure - image: tsakidev/giteacomment:latest + image: tsakidev/giteacomment:1.1.1 settings: gitea_token: from_secret: gitea_token @@ -108,7 +108,7 @@ steps: - reopened - synchronized - name: gitea-pr-comment-success - image: tsakidev/giteacomment:latest + image: tsakidev/giteacomment:1.1.1 settings: gitea_token: from_secret: gitea_token diff --git a/docker-compose.yml b/docker-compose.yml index 092d07f..6262d81 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,10 @@ services: tty: true working_dir: /app command: ["python3", "test.py"] + networks: + - todo-service + +networks: + todo-service: + driver: bridge -- 2.40.1 From 07749c709e0ad8754c9ee2d0b14fc7c26c50daf3 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:33:52 +0800 Subject: [PATCH 09/15] fix drone config 6 --- .drone.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index e5b9722..1696c37 100644 --- a/.drone.yml +++ b/.drone.yml @@ -93,8 +93,7 @@ steps: settings: gitea_token: from_secret: gitea_token - gitea_base_url: - from_secret: gitea_base_url + gitea_base_url: ${DRONE_REPO_LINK} comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境失败" when: status: @@ -112,8 +111,7 @@ steps: settings: gitea_token: from_secret: gitea_token - gitea_base_url: - from_secret: gitea_base_url + gitea_base_url: ${DRONE_REPO_LINK} comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境成功" when: status: -- 2.40.1 From 97e61f100705fd33c744b184df4664ee455fa365 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:37:54 +0800 Subject: [PATCH 10/15] fix drone config 7 --- .drone.yml | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1696c37..9b121bb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -76,8 +76,7 @@ steps: - git fetch - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - - docker-compose down - - docker-compose up -d --build --force-recreate + - docker-compose down && docker-compose build --no-cache && docker-compose up -d - docker image prune -f when: event: @@ -88,42 +87,6 @@ steps: - opened - reopened - synchronized -- name: gitea-pr-comment-failure - image: tsakidev/giteacomment:1.1.1 - settings: - gitea_token: - from_secret: gitea_token - gitea_base_url: ${DRONE_REPO_LINK} - comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境失败" - when: - status: - - failure - event: - include: - - pull_request - action: - include: - - opened - - reopened - - synchronized -- name: gitea-pr-comment-success - image: tsakidev/giteacomment:1.1.1 - settings: - gitea_token: - from_secret: gitea_token - gitea_base_url: ${DRONE_REPO_LINK} - comment: "${DRONE_PULL_REQUEST_TITLE} 部署 sit 环境成功" - when: - status: - - success - event: - include: - - pull_request - action: - include: - - opened - - reopened - - synchronized -- 2.40.1 From ce40570c938d7ab0e2daf6dc2b83fa189ecabbd3 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:39:11 +0800 Subject: [PATCH 11/15] fix drone config 8 --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 9b121bb..c30b8d1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -77,7 +77,6 @@ steps: - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - docker-compose down && docker-compose build --no-cache && docker-compose up -d - - docker image prune -f when: event: include: -- 2.40.1 From 8ea68aabfef6e5a127de8b99d126e3e515260c70 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:41:43 +0800 Subject: [PATCH 12/15] fix drone config 9 --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index c30b8d1..833a4a2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,8 +33,7 @@ steps: - git fetch - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - - docker-compose down - - docker-compose up -d --build --force-recreate + - docker-compose down && docker-compose build --no-cache && docker-compose up -d - docker image prune -f when: event: @@ -77,6 +76,7 @@ steps: - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - docker-compose down && docker-compose build --no-cache && docker-compose up -d + - docker image prune -f when: event: include: -- 2.40.1 From da5b84e5c9f2cbe48230620087b99177fbf19203 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:43:57 +0800 Subject: [PATCH 13/15] fix drone config 10 --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 833a4a2..c7d017f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,7 +33,7 @@ steps: - git fetch - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - - docker-compose down && docker-compose build --no-cache && docker-compose up -d + - docker-compose up -d --build --force-recreate - docker image prune -f when: event: @@ -75,7 +75,7 @@ steps: - git fetch - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - - docker-compose down && docker-compose build --no-cache && docker-compose up -d + - docker-compose up -d --build --force-recreate - docker image prune -f when: event: -- 2.40.1 From b5ecdc9eefe244475c62afae14edab8da8143997 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:46:44 +0800 Subject: [PATCH 14/15] fix drone config 11 --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index c7d017f..cd36906 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,6 +33,7 @@ steps: - 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 when: @@ -75,6 +76,7 @@ steps: - 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 when: -- 2.40.1 From 7e3fe006051e3437299f9fe63c8a3cd2048bb313 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sun, 9 Jul 2023 05:50:21 +0800 Subject: [PATCH 15/15] fix drone config 12 --- .drone.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/.drone.yml b/.drone.yml index cd36906..8cb5831 100644 --- a/.drone.yml +++ b/.drone.yml @@ -90,4 +90,48 @@ steps: - synchronized +--- +kind: pipeline +type: docker +name: main-pull-request-staging + +platform: + os: linux + arch: amd64 + +trigger: + branch: + include: + - main + +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 + when: + event: + - pull_request + action: + include: + - opened + - reopened + - synchronized -- 2.40.1