fortrabbit + Codeship
We have got a lot of requests concerning continuous integration lately. That’s why we’ve published a new general article in our docs on how to integrate CI in your fortrabbit workflow.
Pieter from wercker also just published this great article on how to integrate fortrabbit with wercker. Here is another one from us on how you could something similar combining Codeship with fortrabbit.
You should first create a fresh App on fortrabbit. You could also use an existing one, but it’s simpler to start from the scratch. Now you have to setup a repository on Github or Bitbucket. Best name it the same as your App on fortrabbit… or however you can remember it best. I’d recommend to use a private repo, as long as you don’t plan on going public with your source code. I’ll go with Bitbucket in this example, ‘cause they offer (a limited amount of) private repos for free.
Now you can sign in to codeship with your Bitbucket (or Github) account and create a new repo. Following the create link you can choose your repository provider. I went with Bitbucket and chose my
my-app repository. In the next screen of the setup process codeship tells you how to set up your hook. Follow the instructions and make a first commit and push to your (Bitbucket) repo. Now you need to choose the Technology, i.e. your test environment. Choose PHP in the top select bar. If you need (I didn’t) modify the setup and test commands.
Setup your fortrabbit App
You need to install your codeship project’s SSH key in your fortrabbit App so that codeship will be allowed to push to fortrabbit. You can find the key in the General tab of your project’s settings. Copy and paste the key as a new user in the Git tab of your App on fortrabbit.
Setup deployment: codeship -> fortrabbit
This is final step. Go again to your project settings on codeship and open the Deployment tab. Choose $script from the buttons and enter the following in the deployment command (modify according to your App’s Git URL and App name):
git remote | grep -q frbit-master || git remote add frbit-master email@example.com:my-app.git git push frbit-master master
It should look alike to (the textarea breaks the lines, but it should be two, not three):
Commit, push, test and deploy
Well, you did it. Now just do you first code, test & deploy cycle. For this you need of course something testable. Here is a demo app you can use if you haven’t one at your fingertips. Add your code, commit everything and push (to Bitbucket):
$ git add -A $ git commit -am 'Test and deploy' $ git push
On codeship, you should see something like this: And on fortrabbit, your code has been deployed!
Going multi stage
No problem. With codeship, you can setup a different deployment script for each branch. So assuming you followed our multi stage guide and read the extension about CI and multi-stage, just modify the deploy script on codeship for each branch like so (of course: replace the actual App Git URLs): test branch
git remote | grep -q frbit-test || git remote add frbit-test firstname.lastname@example.org:my-app-test.git git push frbit-master refs/heads/test:refs/heads/master
git remote | grep -q frbit-stage || git remote add frbit-stage email@example.com:my-app-stage.git git push frbit-master refs/heads/stage:refs/heads/master
git remote | grep -q frbit-prod || git remote add frbit-prod firstname.lastname@example.org:my-app-prod.git git push frbit-master refs/heads/prod:refs/heads/master
Disclaimer: Of course wercker and Codeship are not the only “Continuous Integration as a Service” providers. You might also have a look at CircleCI, TravisCI or others. fortrabbit is definitely also not the only place to host your PHP application, but maybe the coolest. Don’t forget to check out our big list of developer facing services.