|
2 | 2 | set -e
|
3 | 3 | set -x
|
4 | 4 |
|
5 |
| -CURRENT_BRANCH="main" |
| 5 | +function remote() { |
| 6 | + git remote add $1 $2 || true |
| 7 | +} |
6 | 8 |
|
7 | 9 | function split() {
|
8 |
| - # https://github.com/splitsh/lite |
9 |
| - SHA1=`./bin/splitsh-lite --prefix=$1` |
10 |
| - git push $2 "$SHA1:refs/heads/$CURRENT_BRANCH" -f |
| 10 | + # Set up the correct SSH key for each repo |
| 11 | + # Without this it will just use the first |
| 12 | + # key it finds which will likely not be correct |
| 13 | + if [ -n "$GITHUB_ACTIONS" ] |
| 14 | + then |
| 15 | + export GIT_SSH_COMMAND="ssh -i /home/runner/.ssh/$2 -o IdentitiesOnly=yes" |
| 16 | + fi |
| 17 | + git subtree push --prefix $1 $2 main |
11 | 18 | }
|
12 | 19 |
|
13 |
| -function remote() { |
14 |
| - git remote add $1 $2 || true |
| 20 | +# Inspired by https://maxschmitt.me/posts/github-actions-ssh-key/ |
| 21 | +# This is so we can run this as part of a github action and push |
| 22 | +# code out to the mirrors |
| 23 | +function addSshKey() { |
| 24 | + # This only runs in a github action, since your local |
| 25 | + # ssh key will already have push access to the mirrors |
| 26 | + if [ -n "$GITHUB_ACTIONS" ] |
| 27 | + then |
| 28 | + mkdir -p /home/runner/.ssh |
| 29 | + ssh-keyscan github.com >> /home/runner/.ssh/known_hosts |
| 30 | + printenv $2 > /home/runner/.ssh/$1 |
| 31 | + chmod 600 /home/runner/.ssh/$1 |
| 32 | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null || true |
| 33 | + ssh-add /home/runner/.ssh/$1 |
| 34 | + fi |
15 | 35 | }
|
16 | 36 |
|
17 |
| -git pull origin $CURRENT_BRANCH |
| 37 | +addSshKey sdks-node METRICS_SDK_NODE_PRIVATE_KEY |
| 38 | +addSshKey sdks-php METRICS_SDK_PHP_PRIVATE_KEY |
| 39 | +addSshKey sdks-python METRICS_SDK_PYTHON_PRIVATE_KEY |
| 40 | +addSshKey sdks-ruby METRICS_SDK_RUBY_PRIVATE_KEY |
| 41 | +addSshKey sdks-dotnet METRICS_SDK_DOTNET_PRIVATE_KEY |
18 | 42 |
|
19 | 43 | remote sdks-node [email protected]:readmeio/metrics-sdks-node.git
|
20 | 44 | remote sdks-php [email protected]:readmeio/metrics-sdks-php.git
|
|
0 commit comments