Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
garp3/deploy/tasks/git.cap
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (18 sloc)
788 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |