jirutka / rake-jekyll

Rake tasks for Jekyll as a gem.
MIT License
30 stars 3 forks source link

Deploying with Travis CI doesn't pick up GH_TOKEN #10

Closed stevemoser closed 9 years ago

stevemoser commented 9 years ago

I believe I followed the instructions to the letter. I use the same encrypted token on a middleman deployment through Travis CI and it works fine. Any ideas?

git push -q https://github.com/stevemoser/stevemoser.org.git gh-pages:gh-pages
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/stevemoser/stevemoser.org.git/'
rake aborted!

https://travis-ci.org/stevemoser/stevemoser.org

razor-x commented 9 years ago

Normally the way the token works is that it would be part of this URL:

git push -q https://github.com/stevemoser/stevemoser.org.git gh-pages:gh-pages`

But then you wouldn't actually ever want the URL to appear in a build log as that would compromise the token. I recommend using deploy keys instead. I am doing this with this gem (example here: https://github.com/razor-x/jekyll-and-zurb/blob/master/Rakefile#L127-L166).

Hopefully the new version will come out soon which adds full support for this.

stevemoser commented 9 years ago

Why not just write that part of the log to dev/null by tacking this on the end? > /dev/null 2>&1

jirutka commented 9 years ago

@stevemoser I have no idea what’s wrong here, this should work out-of-box. Are you sure that you have GH_TOKEN=your-token encrypted in your .travis.yml?

Normally the way the token works is that it would be part of this URL…

The rake task takes care of it.

However, as we can see in Travis log, it didn’t work in this case.

Expected: git push -q https://***:***@github.com/stevemoser/stevemoser.org.git gh-pages:gh-pages
Actual:   git push -q https://github.com/stevemoser/stevemoser.org.git gh-pages:gh-pages

But then you wouldn't actually ever want the URL to appear in a build log as that would compromise the token.

No worry, this has been already fixed, token is never printed to log (see here).

I’ll look at this problem.

stevemoser commented 9 years ago

nm, looks like it might have been a problem with my key? I just tried a different one and it worked... Maybe assert that the key is good and warn the user that there is an issue with the key?

jirutka commented 9 years ago

@stevemoser It’s not necessary to validate that the token is correct (if not, deploy will simply not work). However, it seems that in your case the GH_TOKEN variable hadn’t exist at all. I can simply check if GH_TOKEN or deploy key exist; if not, it’s most likely error, so user should be warned. I’ve implemented it in 28827087d075b10279134edbd29103afe5389e32.