From c0e06b337ffa2ed3d87ac4884226c09efb71a818 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 12 May 2021 10:19:40 +0700 Subject: [PATCH] #5 added drone file --- .drone.yml | 82 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 16 --------- 2 files changed, 82 insertions(+), 16 deletions(-) create mode 100644 .drone.yml delete mode 100644 docker-compose.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..e0b00ac --- /dev/null +++ b/.drone.yml @@ -0,0 +1,82 @@ +kind: pipeline +name: build +type: docker + +platform: + os: linux + arch: amd64 + +steps: + - name: compress + image: alpine + commands: + - rm -rf ./app.tar.bz2 + - tar -cjf ./app.tar.bz2 -C ./ . + - name: upload + image: drillster/drone-rsync + when: + branch: + - master + environment: + RSYNC_KEY: + from_secret: rsync_key + RSYNC_USER: + from_secret: rsync_user + PLUGIN_ARGS: -zz -O --no-perms + settings: + port: 22522 + hosts: + - vault48.org + source: ./ + user: ${rsync_user} + key: ${rsync_key} + target: /tmp/tg-bot-${DRONE_BRANCH} + include: + - "app.tar.bz2" + exclude: + - "*" + - name: build + image: appleboy/drone-ssh + when: + branch: + - master + environment: + BUILD_PATH: + from_secret: build_path + ENV_PATH: + from_secret: env_path + settings: + host: vault48.org + username: + from_secret: rsync_user + key: + from_secret: rsync_key + envs: [build_path, env_path] + port: 22522 + script_stop: true + script: + - mkdir -p $${BUILD_PATH}/${DRONE_BRANCH} + - rm -rf $${BUILD_PATH}/${DRONE_BRANCH}/* + - cd $${BUILD_PATH}/${DRONE_BRANCH} + - tar -xjf /tmp/tg-bot-${DRONE_BRANCH}/app.tar.bz2 -C ./ + - cp -a $${ENV_PATH}/${DRONE_BRANCH}/. $${BUILD_PATH}/${DRONE_BRANCH} + - docker-compose -f ./docker/docker-compose.yml build + - docker-compose -f ./docker/docker-compose.yml up -d + - name: telegram_notify + image: appleboy/drone-telegram + when: + status: + - success + - failure + settings: + token: + from_secret: telegram_token + to: + from_secret: telegram_chat_id + format: markdown + message: > + {{#success build.status}}🤓{{else}}😨{{/success}} + [{{repo.name}} / {{commit.branch}}]({{ build.link }}) + ``` + {{ commit.message }} + ``` diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index e175a50..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3.4' -services: - db: - container_name: bot-db - image: postgres:11-alpine - ports: - - 5432:5432 - environment: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - POSTGRES_DB: bot - volumes: - - bot-db:/var/lib/postgresql/data - - /etc/localtime:/etc/localtime:ro -volumes: - bot-db: {}