paratrooper icon indicating copy to clipboard operation
paratrooper copied to clipboard

deploy current branch error or am I missing something?

Open stefanosc opened this issue 10 years ago • 11 comments

I just had a look at the latest commit https://github.com/mattpolito/paratrooper/commit/341f9f213de2b1b6a71d807e00ccbc3218d1fabf

And followed the various conversations around this, including pull https://github.com/mattpolito/paratrooper/pull/53

As part of my deploy task I tried various options:

Paratrooper::Deploy.new("myapp-staging", tag: 'staging', branch: "HEAD")
Paratrooper::Deploy.new("myapp-staging", tag: 'staging', branch: :head)

as described in lib/paratrooper/deploy.rb

And I get this:

Fetching repository, done.
error: src refspec refs/heads/HEAD does not match any.
error: failed to push some refs to '[email protected]:myapp-staging.git'

If I don't pass any :branch value to the Deploy instance then it only deploys the master branch.

is there a way to simply deploy the current branch to staging without having to manually edit the rake task with the branch name?

Thank you very much

stefanosc avatar Jul 31 '14 20:07 stefanosc

What scenario are you trying to make happen with this declaration? Paratrooper::Deploy.new("myapp-staging", tag: 'staging', branch: :head)

mattpolito avatar Aug 01 '14 01:08 mattpolito

@mattpolito I would like to deploy the branch from which I execute the rake deploy command. When reading the comments:

# :branch                - String name to be used as a git reference
#                          point for deploying from specific branch
#                          point for deploying from specific branch.
#                          Use :head to deploy from current branch

I understand that I need to set :branch to :head but it throws an error as I wrote. Am I missing something?

stefanosc avatar Aug 01 '14 10:08 stefanosc

This is a brand new feature that came in via a PR. I have yet to use it. Let me look into it and see if I can help. Sorry that it's not working out for you.

mattpolito avatar Aug 01 '14 12:08 mattpolito

@mattpolito thank you. I did notice the commit is just from a few days ago! Meanwhile I found a solution which seems to be how the script should work:

branch = `git rev-parse --abbrev-ref HEAD`
deployment = Paratrooper::Deploy.new("myapp-staging", tag: 'staging', branch: branch )

Let me know if this helps and if you see anything else. Thanks

stefanosc avatar Aug 01 '14 12:08 stefanosc

@stefanosc did you have an issue when using the symbolized :head branch name? I definitely see an issue when "HEAD" is used but looks like it would have worked with :head.

mattpolito avatar Aug 02 '14 01:08 mattpolito

@mattpolito same issue

============================================================
>> Pushing refs/heads/head to Heroku
============================================================

Fetching repository, done.
error: src refspec refs/heads/head does not match any.
error: failed to push some refs to '[email protected]:myapp-staging.git'

stefanosc avatar Aug 02 '14 05:08 stefanosc

@mattpolito Just a quick update: I was able to push / deploy any current branch as per my https://github.com/mattpolito/paratrooper/issues/69#issuecomment-50878785

Then I tried again today and ran into another issue:

❯❯❯ rake deploy:staging                                                                          ✭ ✱

============================================================
>> Updating Repo Tag: staging
============================================================

Everything up-to-date

============================================================
>> Pushing refs/heads/mod-11
 to Heroku
============================================================

Fetching repository, done.
Everything up-to-date
sh: line 1: :refs/heads/master: No such file or directory

============================================================
>> Accessing myapp-staging.herokuapp.com to warm up your application
============================================================

I am not sure what happened but nothing works today.

then I noticed at https://devcenter.heroku.com/articles/git

git push heroku yourbranch:master

For the time being I pushed without paratrooper. It would be handy to be able to easily push local branches to staging. Let me know if I can help in some way.

stefanosc avatar Aug 15 '14 15:08 stefanosc

@stefanosc This one has really been messing with me. Under the current master branch I cannot reproduce what you are seeing. Are you still having issues?

mattpolito avatar Aug 19 '14 12:08 mattpolito

@mattpolito thank you for looking into this. The only issue happens when deploying from a branch other than master. So, yes, you would not be able to reproduce the above if you try to deploy from your master branch. In case of any misunderstanding: I am trying to find a way to deploy "current branch" (non master branch). I am definitely still having issues with this and I am only able to deploy master branch, any attempt to deploy any other branch fails.

Let me know if there is anything I can do. Thank you

stefanosc avatar Aug 19 '14 12:08 stefanosc

I do have this working on current master (0360076) but it works very unintuitively:

Paratrooper::Deploy.new app_name,
  ...other args...
  tag: environment,                    # production, staging, canary, etc...
  branch: ref == 'HEAD' ? :head : nil, # explicit HEAD or non-canonical git ref which can be either a tag or a branch name
  match_tag: ref                       # explicit HEAD or non-canonical git ref which can be either a tag or a branch name

This way I can specify a tag name environment for each of my environments, and a git ref ref for what I want to deploy.

debreczeni avatar Oct 06 '14 16:10 debreczeni

@debreczeni thank you for posting your solution. I am not sure I can follow. What is ref? And how does it work if you set the match_tag to nil if you are not in HEAD branch?

I had created the following staging rake task which worked initial but I can figure out what's wrong with it now:

namespace :deploy do
  desc 'Deploy app in staging environment'
  task :staging do
    branch = `git rev-parse --abbrev-ref HEAD`
    deployment = Paratrooper::Deploy.new("loveflix-staging", tag: 'staging', branch: branch )

    deployment.deploy
  end
...
end

Thanks!

stefanosc avatar Oct 11 '14 16:10 stefanosc