Last active
September 11, 2017 13:08
-
-
Save wujku/eef7678a3d5b9fed910db2eb86c296ce to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# Usage: repository=repository_name.git worktree=/home/user/domains/domain.name gitlab_deployment_configuration.sh | |
if [ -z ${repository+x} ]; then repository=gitlab.git; fi | |
if [ -z ${worktree+x} ]; then worktree=/home/ubuntu/domains/domain.name; fi | |
# create git --bare repository | |
git init --bare ${repository} | |
cd ${repository} | |
# create post-receive hook | |
bash -c "cat >> hooks/post-receive" <<'EOL' | |
#!/bin/sh | |
read OLDREV NEWREV REFNAME | |
WORKTREE=`git config core.worktree` | |
# checkout current commit | |
echo "git checkout develop --force" | |
git checkout develop --force | |
EOL | |
# add execute permission | |
chmod +x hooks/post-receive | |
git config core.worktree ${worktree} | |
git config core.bare false | |
git config receive.denyCurrentBranch ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment