kind: pipeline type: docker name: deploy platform: os: linux arch: amd64 volumes: - name: ssh temp: {} 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 steps: - name: configure-environment pull: always image: ubuntu:latest volumes: - name: ssh path: /root/.ssh environment: SSH_PRIVATE_KEY: from_secret: dokku_ssh_key JUMP_PRIVATE_KEY: from_secret: dokku_ssh_key commands: - mkdir -p ~/.ssh - 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 - chmod 400 ~/.ssh/config - 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 - chmod 400 ~/.ssh/config.jump - chmod 400 ~/.ssh/config.dokku - echo "$JUMP_PRIVATE_KEY" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - name: add-remote image: bitnami/git:2.39.2 volumes: - name: ssh path: /root/.ssh commands: - git remote add dokku dokku:$DOKKU_APP_NAME - ssh jump "echo 'Host key added'" - ssh dokku "echo 'Host key added'" - name: create-app image: bitnami/git:2.39.2 volumes: - name: ssh path: /root/.ssh commands: - ssh dokku dokku apps:exists $DOKKU_APP_NAME - if [ $? -eq 0 ]; then ssh dokku dokku apps:create $DOKKU_APP_NAME; else echo "App already exists"; fi - name: push-to-dokku image: bitnami/git:2.39.2 volumes: - name: ssh path: /root/.ssh commands: - git push dokku $BRANCH trigger: branch: - main