gitgithubcapistrano.netrc

Capistrano ignoring netrc file


I have a PHP web application that I am using Capistrano to deploy. My company moved from using a local git repository to storing our code on Github.

Due to some issues beyond our control we cannot use SSH to clone our Github repo. Instead we have to use https. We've setup a read only user on our Github account so that we can use a netrc file to pull from Github over HTTPS without prompting for a username and password.

This works as hoped on the command line, however, from the Capistrano script it still prompts for a username and password. Here is my deploy.rb for my Capistrano script:

require 'capistrano/php'

set :application, "app"
set :repository,  "https://github.com/mycompany/app.git"
set :deploy_to, "/var/www/html/app"

set :scm, :git
set :deploy_via, :remote_cache
set :copy_exclude, %w(.git)
set :git_enable_submodules, true
default_run_options[:pty] = true
set :use_sudo, true

role :web, "webbox01"
role :app, "webbox01"

Again, doing a git clone https://github.com/mycompany/app.git from the command line directly works fine, but in the deploy.rb it fails. If I manually enter in the username and password of the user into the URL like this https://rouser:password@github.com/mycompany/app.git the Capistrano script works fine.

I'd like to not have to hardcode the username and password in the file if I can avoid it, but if I have to do it, I have to do it.

Thanks in advance for any advice you can offer.


Solution

  • Go to the servers where you did deployed before with capistrano and edit the cached git config file in the shared capistrano dir.

    shared/cached-copy/.git/config

    Remove there any left user name in the origin part so your url looks like : https://github.com/mycompany/app.git