Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Local Path #34

Open
will3m opened this issue Mar 28, 2014 · 8 comments
Open

Project Local Path #34

will3m opened this issue Mar 28, 2014 · 8 comments

Comments

@will3m
Copy link

will3m commented Mar 28, 2014

Is it possible to set the project's local root path in the config file? It would be very useful for deploying multiple git projects at once using only one config file.

If not, what would be the easiest approach of implementing this feature? E.g. which functions are important...

Thanks for this awesome script!

PS: I know I'm trying my luck here. The neatly typed usage document, states that one should drop the deploy script within a project. It suggests that one should have git-deploy-php and a set of config file for each git project.

@pocketarc
Copy link
Owner

@will3m This isn't possible at the moment, but it definitely sounds interesting, and your suggested implementation is actually quite simple, so I might add that.

For now, though, let me share a bit about a workaround I have been doing, you may find that it suits you.

I keep all my projects in a folder called "htdocs". All of them have a deploy.ini (they don't have the git-deploy file). I have a "deploy" command in my system path, that does the following:

#!/bin/sh
php /path/to/git-deploy-php/git-deploy --repo /path/to/htdocs/$1 "${@:2}" /path/to/htdocs/$1/deploy

With that, I can write a command like "deploy project1 && deploy project2 && deploy project3", and they're all deployed at the same time. You could even save that as a "deploythreeprojects" command, and then you'd only need to type that.

@will3m
Copy link
Author

will3m commented Mar 29, 2014

@BrunoDEBARROS Thanks for the quick reply. Passing the arguments (with shifting) in bash is a nifty trick I learned yesterday. Your suggestion would be very useful if I was at liberty to use shell scripts. That said I'm sure others will benefit from this feature whether they are using bash scripts or not.

In the main function where git is instantiated one can just move that line into the for each server loop and then replace the parameter with a variable from config file. I not gotten around to test though. I'm sure my quick hack will break your --repo option.

The idea, for me, is to run php git-deploy-php staging here's a hypothetical example of what my deploy structure looks like.

deploy-root
|-- framework1
|   |-- client-config1
|   |-- client-config2
|-- framework2
|   |-- client-config3
|   |-- client-config4
|-- git-deploy-php
|-- staging.ini
`-- production.ini

-- Personally I would automate it using a script like you suggested.

@pocketarc
Copy link
Owner

What I was thinking about doing, actually, is have a "repository" option in the .ini files that you could use to override the repository to use for deploying. 

What that'd mean is that you could have a folder with git-deploy and a deploy.ini that contained the deploy configs for your projects, along with their repo paths, so that when you did "git-deploy", it'd automatically deploy all of your projects. 

That sounds clean and simple to me. Thoughts?

@will3m
Copy link
Author

will3m commented Mar 31, 2014

My thoughts exactly. The structure was mainly to illustrate that one repository may contain more than one deployment strategy. Essentially the repositories could be scattered all over and still be deployed from a single "git-deploy".

@pocketarc
Copy link
Owner

It sounds like a great idea; I'll try to add this to git-deploy-php as soon as possible.

@will3m
Copy link
Author

will3m commented Apr 4, 2014

Here's how I got it working, sorry for not sending a push request.

Main (added path var)

  foreach ($servers as $server) {

    # Sets the repo path config has priority over application argument
    if (is_array($server->server) && array_key_exists('repo_path', $server->server))
      $path = $server->server['repo_path'];
    else
      $path = $args['repo_path'];

    $git = new Git($path);

Config (added repo_path)

# Throw in some default values, in case they're not set.
$options = array_merge(array(
  'skip' => false,
  'scheme' => 'ftp',
  'host' => '',
  'user' => '',
  'branch' => null,
  'pass' => '',
  'port' => 21,
  'path' => '/',
  'repo_path' => '',
  'passive' => true,
  'clean_directories' => array(),
  'ignore_files' => array(),
  'upload_untracked' => array()
), $options);

Let me know if it makes sense.

@newelement
Copy link

I need a little assistance with this. I have deploy.ini and git-deploy in the same folder. My actual repo exists in a folder next to them called repo. How to I use the subdirectory repo ?

@pocketarc
Copy link
Owner

You can use the --repo command line option to specify a path. I don't believe we've added this 'repo_path' .ini option yet. Alternatively, you can put the deploy.ini in your repo, and then just doing git-deploy /path/to/repo/deploy.ini.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants