dokku_test_deploy/.drone.yml

72 lines
1.9 KiB
YAML
Raw Normal View History

2023-02-21 00:30:26 +00:00
kind: pipeline
type: docker
2023-02-21 00:37:16 +00:00
name: deploy
2023-02-21 00:30:26 +00:00
2023-02-21 01:56:05 +00:00
platform:
os: linux
arch: amd64
volumes:
- name: ssh
temp: {}
2023-02-21 01:23:30 +00:00
environment:
BRANCH: main
DOKKU_HOST: apps1.fnukinternal.net
DOKKU_APP_NAME: dokku-ci-deploy
DOKKU_USER: dokku
JUMP_HOST: 192.168.0.24
JUMP_USER: jumpuser
2023-02-21 00:30:26 +00:00
steps:
2023-02-21 01:23:30 +00:00
- name: configure-environment
2023-02-21 00:37:16 +00:00
pull: always
2023-02-21 02:13:25 +00:00
image: ubuntu:latest
2023-02-21 02:00:03 +00:00
volumes:
- name: ssh
2023-02-21 02:06:50 +00:00
path: /root/.ssh
environment:
2023-02-21 02:00:03 +00:00
SSH_PRIVATE_KEY:
from_secret: dokku_ssh_key
JUMP_PRIVATE_KEY:
from_secret: dokku_ssh_key
2023-02-21 00:37:16 +00:00
commands:
- mkdir -p ~/.ssh
2023-02-21 02:16:14 +00:00
- echo "Host jump\n Hostname $JUMP_HOST\n User $JUMP_USER\n IdentityFile ~/.ssh/id_rsa\n StrictHostKeyChecking no" | tee ~/.ssh/config
- echo "Host dokku\n Hostname $DOKKU_HOST\n User $DOKKU_USER\n IdentityFile ~/.ssh/id_rsa\n StrictHostKeyChecking no\n ProxyCommand ssh -o 'StrictHostKeyChecking no' jump nc %h %p" | tee -a ~/.ssh/config
2023-02-21 01:23:30 +00:00
- chmod 400 ~/.ssh/config
2023-02-21 02:16:14 +00:00
- echo "Host *\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null" | tee ~/.ssh/config.jump
- echo "Host *\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null" | tee ~/.ssh/config.dokku
2023-02-21 01:23:30 +00:00
- chmod 400 ~/.ssh/config.jump
- chmod 400 ~/.ssh/config.dokku
2023-02-21 01:32:36 +00:00
- echo "$JUMP_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
2023-02-21 01:23:30 +00:00
- name: add-remote
2023-02-21 02:00:03 +00:00
image: bitnami/git:2.39.2
volumes:
- name: ssh
2023-02-21 02:06:50 +00:00
path: /root/.ssh
2023-02-21 01:23:30 +00:00
commands:
- git remote add dokku dokku:$DOKKU_APP_NAME
2023-02-21 02:36:15 +00:00
- ssh jump "echo 'Host key added'"
- ssh dokku "echo 'Host key added'"
- name: create-app
2023-02-21 02:39:19 +00:00
image: bitnami/git:2.39.2
2023-02-21 02:36:15 +00:00
volumes:
- name: ssh
path: /root/.ssh
commands:
- ssh dokku apps:exists $DOKKU_APP_NAME
- if [ $? -eq 0 ]; then ssh dokku apps:create $DOKKU_APP_NAME; else echo "App already exists"; fi
2023-02-21 01:23:30 +00:00
- name: push-to-dokku
2023-02-21 02:00:03 +00:00
image: bitnami/git:2.39.2
volumes:
- name: ssh
2023-02-21 02:06:50 +00:00
path: /root/.ssh
2023-02-21 01:23:30 +00:00
commands:
- git push dokku $BRANCH
2023-02-21 00:30:26 +00:00
trigger:
branch:
- main