From 3de7e69a8dfb590310fb7fbf0b2e9bc3459b9686 Mon Sep 17 00:00:00 2001 From: Christopher Hoskin Date: Wed, 4 Dec 2019 14:28:02 +0000 Subject: [PATCH] Merge pull request #2433 from overleaf/csh-issue-308-copybara-script Copybara script GitOrigin-RevId: 6a51a7b4a2205742d45b772cbb8db555240dfa6f --- services/web/bin/invoke-copybara | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 services/web/bin/invoke-copybara diff --git a/services/web/bin/invoke-copybara b/services/web/bin/invoke-copybara new file mode 100755 index 0000000000..edb6b29b55 --- /dev/null +++ b/services/web/bin/invoke-copybara @@ -0,0 +1,22 @@ +#!/bin/bash + +KNOWN_HOSTS=/root/.ssh/known_hosts + +if [[ "$BRANCH_NAME" == "master" ]]; then + set -e + chmod -R 0600 /root/.ssh + ssh-keyscan github.com > $KNOWN_HOSTS + ssh-keygen -lf $KNOWN_HOSTS | grep "SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 github.com" + git config --global user.name Copybot + git config --global user.email copybot@overleaf.com + set +e + copybara --git-committer-email=copybot@overleaf.com --git-committer-name=Copybot + COPYBARA_EXIT_CODE=$? + # Exit codes are documented in java/com/google/copybara/util/ExitCode.java + # 0 is success, 4 is no-op (i.e. no change), anything else is an error + if [[ $COPYBARA_EXIT_CODE -eq 0 || $COPYBARA_EXIT_CODE -eq 4 ]]; then + exit 0 + else + exit $COPYBARA_EXIT_CODE + fi +fi