Created
February 18, 2016 07:08
-
-
Save kimisme9386/87a596ff113630db5830 to your computer and use it in GitHub Desktop.
git hook post recevice for sync to aws codecommit
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 | |
AWS_CODECOMMIT_URL="git-codecommit.us-east-1.amazonaws.com/v1/repos" | |
if [ $(git rev-parse --is-bare-repository) = true ] | |
then | |
REPOSITORY_BASENAME=$(basename "$PWD") | |
REPOSITORY_DIRNAME=$(basename $(dirname "$PWD")) | |
else | |
REPOSITORY_BASENAME=$(basename $(readlink -nf "$PWD"/..)) | |
REPOSITORY_DIRNAME=$(basename $(dirname $(readlink -nf "$PWD"/..))) | |
fi | |
#echo "REPOSITORY is ${REPOSITORY_DIRNAME}_${REPOSITORY_BASENAME}" >> "/tmp/debug_git_hook.txt" | |
AWS_CODECOMMIT_REPOSITORY="${REPOSITORY_DIRNAME}_${REPOSITORY_BASENAME}" | |
AWS_CODECOMMIT_REPOSITORY="${AWS_CODECOMMIT_REPOSITORY:0:${#AWS_CODECOMMIT_REPOSITORY}-4}" | |
git push --mirror "ssh://${AWS_CODECOMMIT_URL}/${AWS_CODECOMMIT_REPOSITORY}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment