With workflows, cloning another repo times out

workflow

#1

Due to our setup our database migrations and seeders are in another repo. Before workflows we had a step that just cloned in the new repo and ran the necessary commands and that is working fine.

With workflows though, that same step suddenly runs into this:

#!/bin/bash
./build/database-migrations.sh
Cloning into '/tmp/database-migrations'...
The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? Too long with no output (exceeded 10m0s)

Not sure if this is a workflows specific thing or not, just seem to notice it only while workflow builds are running. Not sure what would be the best way to resolve this either.


#2

That’s kind of weird- we should have already authorized that host. Are you changing $HOME or using a different user in that context? You might need cp ~/.ssh/known_hosts to somewhere else to authorize that host.


#3

Not at all. The .sh file in question looks like this: (minus some details)

#!/bin/bash

git clone git@github.com:Organization/repo.git /tmp/database-migrations

(
cd /tmp/database-migrations
if [ `git branch -r --list | egrep "^  origin/+${CIRCLE_BRANCH}$"` ]
then
  echo "Checking out branch: '$CIRCLE_BRANCH'"
  git checkout $CIRCLE_BRANCH
fi
)

(cd /tmp/database-migrations && \
composer install --prefer-dist --no-interaction --no-dev --no-progress && \
cp /tmp/api/.env.circleci .env && \
php artisan migrate:refresh --seed)

#4

But I should point out this is happening in a job that doesn’t run y’alls built in checkout command (checkout happens in a separate build job), which I can see is setting up the hosts for github and bitbucket. Most likely related to that?


#5

Oh! Definitely related. Just go grab our command from a different of your 2.0 builds and include those setup lines. This will all work afterwards. It’s just getting your known_hosts configured to accept GitHub without being prompted.


#6

Looks like I just need this part

set -e

# Workaround old docker images with incorrect $HOME
# check https://github.com/docker/docker/issues/2968 for details
if [ "${HOME}" = "/" ]
then
  export HOME=$(getent passwd $(id -un) | cut -d: -f6)
fi

mkdir -p ~/.ssh

echo '
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
' >> ~/.ssh/known_hosts

#7

Follow up for anyone interested, slapping the above code block somewhere in your steps gets the job done.


#8

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.