From c1848d6089a6432e1a85e4ca74077c4e7c4dd3f6 Mon Sep 17 00:00:00 2001 From: Glenn <glenux@glenux.net> Date: Thu, 20 Mar 2025 23:08:11 +0100 Subject: [PATCH] chore(ci): Streamline Drone CI configuration This change simplifies the Drone CI configuration by removing redundant steps and environment variables, enhancing the tagging strategy for Docker images, and improving SSH key handling during deployment. Without this change, the CI pipeline would be more complex and less efficient, with potential issues in Docker image tagging and SSH key management. - Remove unused 'environment' field from 'debug' Signed-off-by: Glenn <glenux@glenux.net> --- .drone.yml | 54 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/.drone.yml b/.drone.yml index fdf3cb3..bc74a9d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,8 +6,6 @@ name: default steps: - name: debug image: alpine - environment: - commands: - 'echo "Repository: glenux/service-monica"' - 'echo "Git commit: ${DRONE_COMMIT_SHA:0:8}"' @@ -25,24 +23,12 @@ steps: from_secret: DOCKERHUB_USERNAME password: from_secret: DOCKERHUB_PASSWORD - cache_from: "glenux/service-monica:latest_${DRONE_BRANCH/\\//-}" + cache_from: "glenux/service-monica:${DRONE_BRANCH/\\//-}_latest" repo: glenux/service-monica - tags: "${DRONE_COMMIT_SHA:0:8}" - purge: false - - - name: publish:commit_branch - image: plugins/docker - # volumes: - # - name: cache - # path: /stupid - settings: - username: - from_secret: DOCKERHUB_USERNAME - password: - from_secret: DOCKERHUB_PASSWORD - cache_from: "glenux/service-monica:latest_${DRONE_BRANCH/\\//-}" - repo: glenux/service-monica - tags: "latest_${DRONE_BRANCH/\\//-}" + tags: + - "${DRONE_BRANCH/\\//-}_${DRONE_COMMIT_SHA:0:8}" + - "${DRONE_BRANCH/\\//-}_latest" + - "latest" purge: false when: branch: @@ -50,21 +36,6 @@ steps: - "develop" - "feature/*" - - name: publish:latest - image: plugins/docker - settings: - username: - from_secret: DOCKERHUB_USERNAME - password: - from_secret: DOCKERHUB_PASSWORD - cache_from: "glenux/service-monica:latest_${DRONE_BRANCH/\\//-}" - repo: glenux/service-monica - tags: latest - purge: false - when: - branch: - - master - - name: deploy:dokku image: alpine when: @@ -85,12 +56,15 @@ steps: - 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 prm \ - "glenux/service-monica:${DRONE_COMMIT_SHA:0:8}" + - ssh-keygen -f ~/.ssh/deploy_key -y > ~/.ssh/deploy_key.pub + - "cat ~/.ssh/deploy_key.pub | cut -f3 -d' '" + - ssh -o StrictHostKeyChecking=no + -i ~/.ssh/deploy_key + "$SSH_USER@$SSH_HOST" + git:from-image prm + "glenux/service-monica:${DRONE_BRANCH/\\//-}_${DRONE_COMMIT_SHA:0:8}" + # + - echo "SUCCESS" # volumes: # - name: cache