Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heroku app doesn't contain .ssh/config after build #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

ENV_DIR=${3:-}
BUILD_DIR=$1

git_ssh_key="$(cat $ENV_DIR/GIT_SSH_KEY)"
git_ssh_host="$(cat $ENV_DIR/GIT_SSH_HOST)"
Expand All @@ -10,22 +11,22 @@ if [ "$git_ssh_key" != "" ] && [ "$git_ssh_host" != "" ]; then
echo "" >&1

# Ensure that we have the SSH directory
if [ ! -d ~/.ssh ]; then
mkdir -p ~/.ssh
chmod 700 ~/.ssh
if [ ! -d $BUILD_DIR/.ssh ]; then
mkdir -p $BUILD_DIR/.ssh
chmod 700 $BUILD_DIR/.ssh
fi

# Load the git SSH key into a file
echo $git_ssh_key | base64 --decode > ~/.ssh/git_key
echo $git_ssh_key | base64 --decode > $BUILD_DIR/.ssh/git_key

# Change the permissions on the file to be read-write for this user
chmod 600 ~/.ssh/git_key
chmod 600 $BUILD_DIR/.ssh/git_key

# Set up the SSH config file
echo -e "Host $git_ssh_host\n"\
" IdentityFile ~/.ssh/git_key\n"\
" IdentitiesOnly yes\n"\
" UserKnownHostsFile=/dev/null\n"\
" StrictHostKeyChecking no"\
> ~/.ssh/config
> $BUILD_DIR/.ssh/config
fi