diff --git a/bin/add_host_to_ssh_known_hosts b/bin/add_host_to_ssh_known_hosts new file mode 100755 index 00000000..1d1b27c0 --- /dev/null +++ b/bin/add_host_to_ssh_known_hosts @@ -0,0 +1,10 @@ +#!/bin/bash -eu + +# Parameter can be just a host name, or a full http, https or git URL. +URL="${1:?You need to provide an URL as first parameter}" + +# Use a RegEx to extract the $HOST. Match the optional `http://`, `https://` or `git@` at the start, then capture everything after that up to the next `/` or `:`. +[[ $URL =~ ^(https?://|git@)?([^/:]+) ]] && HOST=${BASH_REMATCH[2]} + +echo "Adding ${HOST} to '~/.ssh/known_hosts'..." +for ip in $(dig @8.8.8.8 "${HOST}" +short); do ssh-keyscan "${HOST}",$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true diff --git a/bin/install_swiftpm_dependencies b/bin/install_swiftpm_dependencies index 9f6eb5db..9b2226c7 100755 --- a/bin/install_swiftpm_dependencies +++ b/bin/install_swiftpm_dependencies @@ -3,10 +3,7 @@ sudo defaults write com.apple.dt.Xcode IDEPackageSupportUseBuiltinSCM YES # Trust all GitHub.com and BitBucket.org keys – this allows checking out dependencies via SSH -for ip in $(dig @8.8.8.8 bitbucket.org +short); do ssh-keyscan bitbucket.org,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true -echo ":bitbucket: Added BitBucket IP Addresses to known_hosts" - -for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true -echo ":github: Added GitHub IP Addresses to known_hosts" +add_host_to_ssh_known_hosts bitbucket.org +add_host_to_ssh_known_hosts github.com xcodebuild -resolvePackageDependencies diff --git a/bin/publish_private_pod b/bin/publish_private_pod index 9d5a7910..ce25d9e6 100755 --- a/bin/publish_private_pod +++ b/bin/publish_private_pod @@ -12,8 +12,11 @@ ssh-add -D ssh-add ~/.ssh/pod_repo_push_deploy_key ssh-add -l +# Add the host of the spec repo (typically github.com) to the known_hosts to be sure we can clone it via ssh +add_host_to_ssh_known_hosts "$PRIVATE_SPECS_REPO" + # For some reason this fixes a failure in `lib lint` # https://github.com/Automattic/buildkite-ci/issues/7 xcrun simctl list >> /dev/null -bundle exec pod repo push $PRIVATE_SPECS_REPO $PODSPEC_PATH +bundle exec pod repo push "$PRIVATE_SPECS_REPO" "$PODSPEC_PATH"