pocketarc / git-deploy-php

git-deploy-php is a simple php-based tool that deploys your Git repositories to FTP/SFTP servers, and keeps them updated automatically.
http://brunodebarros.github.io/git-deploy-php
291 stars 45 forks source link

Project Local Path #34

Open will3m opened 10 years ago

will3m commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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

will3m commented 10 years ago

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 commented 8 years ago

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 commented 8 years ago

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.