Created
July 2, 2014 19:18
-
-
Save elmariofredo/9737d41b89b598a09d2f to your computer and use it in GitHub Desktop.
Simple PHP deploy script using git, inspired by capistrano magic. Just run ./php-deploy.sh BRANCH-NAME and target apache to /srv/app/public folder.
This file contains 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
#!/bin/bash | |
project_name=app | |
project_url=git@github.com:some/repo.git | |
target_branch=$1 | |
if [ ! -d "/srv/$project_name/repo" ] | |
then | |
echo "Setting up repo for the firts time" | |
mkdir -p /srv/$project_name/repo | |
mkdir -p /srv/$project_name/public | |
git clone --mirror $project_url /srv/$project_name/repo | |
fi | |
cd /srv/$project_name/repo | |
git remote update | |
last_commit_sha=$(git rev-parse $target_branch) | |
if [ ! -d "/srv/$project_name/public/$target_branch" ] | |
then | |
echo "Deploying $last_commit_sha on $target_branch" | |
mkdir -p /srv/$project_name/public/$target_branch | |
git archive $target_branch | tar -x -C /srv/ztrack/public/$target_branch | |
else | |
echo "Deploying $last_commit_sha on $target_branch has been done already" | |
fi | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment