Created
March 3, 2015 04:16
-
-
Save TommyLau/9710c7275d36d3ba1d43 to your computer and use it in GitHub Desktop.
Stash post receive hooks
This file contains hidden or 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 | |
# Make a temp file | |
keyfile=`mktemp` | |
# Get repository to push | |
repository="$1" | |
# Create the private key | |
while shift; do | |
echo "$1" >> $keyfile | |
done | |
chmod 0600 $keyfile | |
# Generate a temp ssh.sh | |
ssh=`mktemp` | |
cat <<-EOF>$ssh | |
#!/bin/bash | |
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $keyfile "\$@" | |
EOF | |
chmod +x $ssh | |
# Push to remote to publish | |
GIT_SSH=$ssh git push --mirror $repository | |
#ssh-agent bash -c "ssh-add $keyfile; git push --mirror $repository >> output.txt" | |
# Remove temp files | |
rm -f $keyfile | |
rm -f $ssh | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment