Created
July 11, 2012 07:03
-
-
Save ConsoleCatzirl/3088550 to your computer and use it in GitHub Desktop.
A script to hook a push to github from another repo being pushed to
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 | |
| # Author: Jonathan Harker <jesusaur@cat.pdx.edu> | |
| REPO=GitHubUser/GitHubRepo.git | |
| KEY="/full/path/to/github.key" | |
| case "$1" in | |
| # Use case 1: | |
| # Call 'github.sh all' in post-receive hook | |
| "all") | |
| echo "Mirroring to github.com" | |
| export GIT_SSH="$0" | |
| git push --mirror git@github.com:$REPO | |
| ;; | |
| # Use case 2: | |
| # Call 'github.sh push' in update hook | |
| "push") | |
| echo "Mirroring branch to github" | |
| export GIT_SSH="$0" | |
| git push git@github.com:$REPO $2 | |
| ;; | |
| # Recursive call to ourselves | |
| *) | |
| exec ssh -i $KEY -o "StrictHostKeyChecking no" "$@" | |
| ;; | |
| esac | |
| exit 0 |
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/sh | |
| # Author: Jonathan Harker <jesusaur@cat.pdx.edu> | |
| # push all changes, making new branches and deleting non-existent branches | |
| /full/path/to/github.sh all |
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/sh | |
| # Author: Jonathan Harker <jesusaur@cat.pdx.edu> | |
| # Push to github | |
| /full/path/to/github.sh push $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment