Skip to content

Instantly share code, notes, and snippets.

@wujku
Last active September 11, 2017 13:08
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 wujku/eef7678a3d5b9fed910db2eb86c296ce to your computer and use it in GitHub Desktop.
Save wujku/eef7678a3d5b9fed910db2eb86c296ce to your computer and use it in GitHub Desktop.
#!/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