Ensure CodeShip works on the named feature branch, not detached HEAD so Composer alias works

Context

Using Composer aliases to make sure your dependencies resolve correctly during development of a feature branch, when CodeShip checks out a detached HEAD this can not longer be seen as expected during the composer install process.

Solution

CodeShip provide some useful default environmental variables to help you set up your build process, and one of those is the branch name in use, so as part of your build tasks before composer runs just add:

git checkout $CI_BRANCH

Then composer can see which feature branch it is on again and the dependency detection will work.