Last active
April 15, 2017 11:38
-
-
Save actual-saurabh/7f8c05941b1173cedd1f77cae76bf6c3 to your computer and use it in GitHub Desktop.
Slim deployment with git archive for deployment tutorial here: https://baapwp.me/2017/04/15/creating-simple-deployment-script-php/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$repositories = array( | |
'custom-theme' => array( | |
'git_url' => '[email protected]/yapapaya/custom-theme.git', | |
'branch' => 'master', | |
'path' => '/var/www/dev.yoursite.com/htdocs/wp-content/themes/', | |
), | |
'custom-plugin' => array( | |
'git_url' => '[email protected]/yapapaya/custom-plugin.git', | |
'branch' => 'master', | |
'path' => '/var/www/dev.yoursite.com/htdocs/wp-content/plugins/' | |
), | |
); | |
if ( ! is_dir( '/var/www/dev.yoursite.com/htdocs/repositories/' ) ) { | |
mkdir( '/var/www/dev.yoursite.com/htdocs/repositories/' ); | |
} | |
$original_dir = getcwd(); | |
foreach ( $repositories as $repo_name => $repo ) { | |
$deploy_path = $repo[ 'path' ] . '/' . $repo_name; | |
if ( ! is_dir( $deploy_path ) ) { | |
mkdir( $deploy_path ); | |
} | |
exec( "git archive --remote={$repo[ 'git_url' ]} {$repo[ 'branch' ]} | (cd " . $deploy_path . " && tar -x)" ); | |
chdir( $original_dir ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment