Permalink
Fetching contributors…
Cannot retrieve contributors at this time
19 lines (18 sloc) 788 Bytes
desc 'Verify user is on the right branch or tag, since assets are built locally'
task :verify_git_branch do
on roles(:app) do
run_locally do
deployTarget = "#{fetch(:branch)}" # convert to string
currentBranch = ENV['TRAVIS_BRANCH'] \
? ENV['TRAVIS_BRANCH'] \
: capture(:git, 'rev-parse --abbrev-ref HEAD')
currentTag = capture(:git, 'describe --exact-match --tags 2>/dev/null || echo 0')
if ((deployTarget != currentBranch) && (deployTarget != currentTag))
abort "\n" \
"Deploy aborted: incorrect branch ⚠️\n\n" \
"It appears you haven't checked out the branch or tag you're trying to deploy. \n" \
"$ git checkout #{fetch(:branch)} && cap #{fetch(:stage)} deploy\n\n" \
end
end
end
end