Search code examples
phpphp-deployer

php deploy build folder only


I am currently using Grunt with grunt-ssh-deploy to deploy the build/ folder after the build is done via an archive, like this:

'ssh-deploy-release': {
        options: {
            localPath: 'build',
            currentReleaseLink: 'current',
            releasesToKeep: 3,
// ...

This is deploying the folder from the local path though, which I can do with deployer with:

task('deploy:staging', function() {
    writeln('<info>Deploying...</info>');
    upload('build/', '{{release_path}}/public');
// ...

but I want to deploy a specific release build from the repo and use php-deployer but I can't find how to only deploy the build folder.

Is it possible to deploy a specific folder from the git repository with deployer?


Solution

  • After some more research and specially https://stackoverflow.com/a/25771130/1280034, I came up with a new deployer task that works for bitbucket (github users might want to use the svn export as said in the comment section):

    task('deploy:folder', function(){
        $branch = env('branch');
        $folder = get('folder');
    
        run("git archive [email protected]:<repo> $branch $folder | tar xvf -")
        // then move the folder content one level
        // ...
    });
    

    It seems that it would also be possible to use a git sparse checkout