From 3f4a63580c77433e7cb7693b77d3bfb09ca6df79 Mon Sep 17 00:00:00 2001 From: Glenn Date: Tue, 21 Feb 2023 14:39:13 +0100 Subject: [PATCH] ci: Add deploy step --- .dockerignore | 2 ++ .drone.yml | 61 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..76ab1a8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.drone.yml +.git diff --git a/.drone.yml b/.drone.yml index 790f402..3d2b119 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,24 +3,33 @@ kind: pipeline type: docker name: default -environment: - DOCKER_REPO: glenux/service-ntfy steps: + - name: debug + image: alpine + environment: + + commands: + - 'echo "Repository: glenux/service-ntfy"' + - 'echo "Git commit: ${DRONE_COMMIT_SHA:0:8}"' + - name: publish:commit_sha image: plugins/docker # pull: never # volumes: # - name: cache # path: /stupid + environment: + DOCKER_REPO: glenux/service-ntfy settings: username: from_secret: DOCKERHUB_USERNAME password: from_secret: DOCKERHUB_PASSWORD cache_from: "${DOCKER_REPO}:latest_${DRONE_BRANCH/\\//-}" - repo: "${DOCKER_REPO}" + repo: glenux/service-ntfy tags: "${DRONE_COMMIT_SHA:0:8}" + purge: false - name: publish:commit_branch image: plugins/docker @@ -32,27 +41,59 @@ steps: from_secret: DOCKERHUB_USERNAME password: from_secret: DOCKERHUB_PASSWORD - cache_from: "${DOCKER_REPO}:latest_${DRONE_BRANCH/\\//-}" - repo: "${DOCKER_REPO}" + cache_from: "glenux/service-ntfy:latest_${DRONE_BRANCH/\\//-}" + repo: glenux/service-ntfy tags: "latest_${DRONE_BRANCH/\\//-}" + purge: false when: branch: - "master" - "develop" - "feature/*" - - name: docker + - name: publish:latest image: plugins/docker settings: - username: "${DOCKERHUB_USERNAME}" - password: "${DOCKERHUB_PASSWORD}" - cache_from: "${DOCKER_REPO}:latest_${DRONE_BRANCH/\\//-}" - repo: "${DOCKER_REPO}" + username: + from_secret: DOCKERHUB_USERNAME + password: + from_secret: DOCKERHUB_PASSWORD + cache_from: "glenux/service-ntfy:latest_${DRONE_BRANCH/\\//-}" + repo: glenux/service-ntfy tags: latest + purge: false when: branch: - master + - name: deploy:dokku + image: alpine + when: + branch: + - master + environment: + SSH_USER: + from_secret: SSH_USER + SSH_HOST: + from_secret: SSH_HOST + SSH_PRIVATE_KEY: + from_secret: SSH_PRIVATE_KEY + commands: + - echo $SSH_USER + - echo $SSH_HOST + - echo $SSH_PRIVATE_KEY + - apk update && apk add openssh-client + - mkdir -p ~/.ssh && chmod 700 ~/.ssh + - echo "$SSH_PRIVATE_KEY" | base64 -d > ~/.ssh/deploy_key + - chmod 600 ~/.ssh/deploy_key + - ssh -o StrictHostKeyChecking=no + -i ~/.ssh/deploy_key + "$SSH_USER@$SSH_HOST" + git:from-image notify + "glenux/service-ntfy:${DRONE_COMMIT_SHA:0:8}" + # + + # volumes: # - name: cache # temp: {}