ci: Add deploy step

This commit is contained in:
Glenn Y. Rolland 2023-02-21 14:39:13 +01:00
parent a71e162625
commit 3f4a63580c
2 changed files with 53 additions and 10 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
.drone.yml
.git

View file

@ -3,24 +3,33 @@ kind: pipeline
type: docker type: docker
name: default name: default
environment:
DOCKER_REPO: glenux/service-ntfy
steps: steps:
- name: debug
image: alpine
environment:
commands:
- 'echo "Repository: glenux/service-ntfy"'
- 'echo "Git commit: ${DRONE_COMMIT_SHA:0:8}"'
- name: publish:commit_sha - name: publish:commit_sha
image: plugins/docker image: plugins/docker
# pull: never # pull: never
# volumes: # volumes:
# - name: cache # - name: cache
# path: /stupid # path: /stupid
environment:
DOCKER_REPO: glenux/service-ntfy
settings: settings:
username: username:
from_secret: DOCKERHUB_USERNAME from_secret: DOCKERHUB_USERNAME
password: password:
from_secret: DOCKERHUB_PASSWORD from_secret: DOCKERHUB_PASSWORD
cache_from: "${DOCKER_REPO}:latest_${DRONE_BRANCH/\\//-}" cache_from: "${DOCKER_REPO}:latest_${DRONE_BRANCH/\\//-}"
repo: "${DOCKER_REPO}" repo: glenux/service-ntfy
tags: "${DRONE_COMMIT_SHA:0:8}" tags: "${DRONE_COMMIT_SHA:0:8}"
purge: false
- name: publish:commit_branch - name: publish:commit_branch
image: plugins/docker image: plugins/docker
@ -32,27 +41,59 @@ steps:
from_secret: DOCKERHUB_USERNAME from_secret: DOCKERHUB_USERNAME
password: password:
from_secret: DOCKERHUB_PASSWORD from_secret: DOCKERHUB_PASSWORD
cache_from: "${DOCKER_REPO}:latest_${DRONE_BRANCH/\\//-}" cache_from: "glenux/service-ntfy:latest_${DRONE_BRANCH/\\//-}"
repo: "${DOCKER_REPO}" repo: glenux/service-ntfy
tags: "latest_${DRONE_BRANCH/\\//-}" tags: "latest_${DRONE_BRANCH/\\//-}"
purge: false
when: when:
branch: branch:
- "master" - "master"
- "develop" - "develop"
- "feature/*" - "feature/*"
- name: docker - name: publish:latest
image: plugins/docker image: plugins/docker
settings: settings:
username: "${DOCKERHUB_USERNAME}" username:
password: "${DOCKERHUB_PASSWORD}" from_secret: DOCKERHUB_USERNAME
cache_from: "${DOCKER_REPO}:latest_${DRONE_BRANCH/\\//-}" password:
repo: "${DOCKER_REPO}" from_secret: DOCKERHUB_PASSWORD
cache_from: "glenux/service-ntfy:latest_${DRONE_BRANCH/\\//-}"
repo: glenux/service-ntfy
tags: latest tags: latest
purge: false
when: when:
branch: branch:
- master - 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: # volumes:
# - name: cache # - name: cache
# temp: {} # temp: {}