#!/usr/bin/env bash

set -e
set -x

export GITHUB_TOKEN=${bosh_openstack_cpi_release_github_token}
export SSH_KEY="ssh.key"
echo "${bosh_openstack_cpi_release_github_key}" > ${SSH_KEY}
eval $(ssh-agent)
chmod go-r ${SSH_KEY}
ssh-add ${SSH_KEY}

ssh-keyscan github.com > ~/.ssh/known_hosts

cd bosh-cpi-src-out
echo "Check if latest auto-update commit has already been merged to master"
git fetch origin master:refs/remotes/origin/master
new_commits_available=$(git branch master --contains $(git rev-parse origin/auto-update))
pull_request=$(hub issue | grep "Bump gems") || no_pull_request=$?
if [ -z ${new_commits_available} ]; then
  if [ -v no_pull_request ]; then
    echo "Creating pull-request"
    git checkout auto-update
    hub pull-request -b master -h auto-update -m "Bump gems"
  else
    echo "Open pull-request found: ${pull_request}"
  fi
else
  echo "No new commits available"
fi

#!/usr/bin/env bash

set -e
set -x

export GITHUB_TOKEN=${bosh_openstack_cpi_release_github_token}
export SSH_KEY="ssh.key"
echo "${bosh_openstack_cpi_release_github_key}" > ${SSH_KEY}
eval $(ssh-agent)
chmod go-r ${SSH_KEY}
ssh-add ${SSH_KEY}

cd bosh-cpi-src-out
echo "Check if latest auto-update commit has already been merged to master"
git fetch origin master:refs/remotes/origin/master
new_commits_available=$(git branch master --contains $(git rev-parse origin/auto-update))
pull_request=$(hub issue | grep "Bump gems") || no_pull_request=$?
if [ -z ${new_commits_available} ]; then
  if [ -v no_pull_request ]; then
    echo "Creating pull-request"
    hub pull-request -b master -h auto-update -m "Bump gems"
  else
    echo "Open pull-request found: ${pull_request}"
  fi
else
  echo "No new commits available"
fi

--- 
+++ 
@@ -10,8 +10,6 @@
 chmod go-r ${SSH_KEY}
 ssh-add ${SSH_KEY}
 
-ssh-keyscan github.com > ~/.ssh/known_hosts
-
 cd bosh-cpi-src-out
 echo "Check if latest auto-update commit has already been merged to master"
 git fetch origin master:refs/remotes/origin/master
@@ -20,7 +18,6 @@
 if [ -z ${new_commits_available} ]; then
   if [ -v no_pull_request ]; then
     echo "Creating pull-request"
-    git checkout auto-update
     hub pull-request -b master -h auto-update -m "Bump gems"
   else
     echo "Open pull-request found: ${pull_request}"
Add github.com to the known_hosts

- required for pull-request creation
- also checkout auto-update branch which is required
  for pull-request creation

[#149794797](https://www.pivotaltracker.com/story/show/149794797)

Signed-off-by: Tom Kiemes <2e6bc7bf64c2cabd57fd2be0c1baf57f97b6fecc@sap.com>
