Skip to content

Instantly share code, notes, and snippets.

@kimisme9386
Created February 18, 2016 07:08
Show Gist options
  • Save kimisme9386/87a596ff113630db5830 to your computer and use it in GitHub Desktop.
Save kimisme9386/87a596ff113630db5830 to your computer and use it in GitHub Desktop.
git hook post recevice for sync to aws codecommit
#!/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