Skip to content

Instantly share code, notes, and snippets.

@JacobDB
Last active November 9, 2018 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacobDB/5e38f57ef060a4de62315e30e321cc9e to your computer and use it in GitHub Desktop.
Save JacobDB/5e38f57ef060a4de62315e30e321cc9e to your computer and use it in GitHub Desktop.
Clone a repository, generate a symlink, and protect the deployment folder for use with git-deploy – https://github.com/vicenteguerra/git-deploy
Order Allow,Deny
Deny from all
<Files "deploy.php">
Allow from all
</Files>
<?php
require_once("config.php");
// get the server path
$_PATH = $_SERVER["DOCUMENT_ROOT"];
// get the theme name
preg_match("/\/([0-9a-z-]+)\.git/", REMOTE_REPOSITORY, $_MATCHES);
$_NAME = $_MATCHES ? $_MATCHES[1] : false;
// verify that settings are configured
if (!$_PATH || !$_NAME) {
$_ERROR = !$_PATH && $_NAME ? "\$_PATH is" : ($_PATH && !$_NAME ? "\$_NAME is" : "\$_PATH and \$NAME are");
echo "error! {$_ERROR} not set properly!<br>"; exit;
}
echo "Using \"{$_PATH}\" as website directory...<br>";
echo "Using \"{$_NAME}\" as theme name...<br>";
// clone the repository
if (!exec("/usr/bin/git clone " . REMOTE_REPOSITORY . " " . DIR)) echo "ERROR! Repository was not cloned!<br />";
// generate the symlink
if (!symlink(DIR . "/dist", "{$_PATH}/wp-content/themes/{$_NAME}")) echo "ERROR! Symlink was not created!<br />";
// delete the file
if (!unlink(__FILE__)) echo "ERROR! Delete this file manually!<br>";
echo "initialized!"; exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment