Skip to content

Instantly share code, notes, and snippets.

@g33kidd
Forked from guillaumewuip/gitlab_ci.yml
Created March 13, 2017 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g33kidd/bc6800b22fbe58797b8cd63680c4044a to your computer and use it in GitHub Desktop.
Save g33kidd/bc6800b22fbe58797b8cd63680c4044a to your computer and use it in GitHub Desktop.
Gitlab CI to dokku
###############################################################################
# Variables #
###############################################################################
variables:
DOKKU_HOST: 'host.com'
PROJECT_NAME: 'project_name'
###############################################################################
# Cache #
###############################################################################
cache:
untracked: true
paths:
- node_modules/
key: 'web_dependencies'
###############################################################################
# Templates #
###############################################################################
.deploy_template: &deploy_definition
image: ubuntu
stage: deploy
before_script:
# Install
- apt-get update -y &>/dev/null
- which ssh-keyscan || (apt-get install -y ssh &>/dev/null)
- which git || (apt-get install -y git &>/dev/null)
- which ssh-agent || (apt-get install openssh-client -y)
# Add ssh private key $SSH_DEPLOY_KEY
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_DEPLOY_KEY")
# SSH config
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
# Add dokku to known hosts
- ssh-keyscan -H $DOKKU_HOST >> ~/.ssh/known_hosts
script:
- echo git push dokku@$DOKKU_HOST:$PROJECT_NAME master # debug
- git push dokku@$DOKKU_HOST:$PROJECT_NAME master
###############################################################################
# Stages #
###############################################################################
stages:
- deploy
deploy_to_dokku:
<<: *deploy_definition
only:
- master
environment: production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment