Forked from kimisme9386/git_hook_repo_name_to_aws_codecommit.sh
Created
September 23, 2017 10:21
-
-
Save schan90/4e3f3c0c948b635cdcd6f290476f6308 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