Continuous Deployment with Codeship and Dokku
The following steps will help you successfully deploy from Codeship to Dokku, so everytime you push to GitHub, Codeship will automatically run the deployment script as long as your tests pass.
This will not take long to implement. You only need the public ssh key from your Codeship project and the bash script below.
Save the public key of the Codeship project. It is found in Project Settings => General Settings.
In project repo create a folder labeled
tmpat the top level, then save the ssh key as
Make sure you add
.gitignorebefore pushing to GitHub. You may want to use a seperate branch for this, or even a submodule.
Make sure when pasting, all the contents are in a single line and not multiple lines.
Add the public key to your dokku server using the following command in console.
cat tmp/codeship_projectname.pub | ssh root(at)your-dokku-server.com "sudo sshcommand acl-add dokku codeship_projectname"
- In Codeship, go to Project Settings => Deployment. Configure your deployment pipeline.
- Add the following lines to the custom script.
#!/bin/sh git fetch --unshallow || true git fetch origin "+refs/heads/*:refs/remotes/origin/*" # checkout a remote branch with: # git checkout -b test origin/test git remote add dokku dokku@[your-dokku-instance].com:projectname git push dokku master