Skip to content

Commit 941c481

Browse files
committed
Merge pull request #4174 from clayzermk1/issue-4172
fix(builder): always configure SSH key
2 parents fa57b1f + 596b278 commit 941c481

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

  • builder/rootfs/usr/local/src/slugbuilder/builder

builder/rootfs/usr/local/src/slugbuilder/builder/build.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ export HOME="$app_dir"
6969
export REQUEST_ID=$(openssl rand -base64 32)
7070
export STACK=cedar-14
7171

72+
## SSH key configuration
73+
74+
if [[ -n "$SSH_KEY" ]]; then
75+
mkdir -p ~/.ssh/
76+
chmod 700 ~/.ssh/
77+
78+
echo $SSH_KEY | base64 -d > ~/.ssh/id_rsa
79+
chmod 400 ~/.ssh/id_rsa
80+
81+
echo 'StrictHostKeyChecking=no' > ~/.ssh/config
82+
chmod 600 ~/.ssh/config
83+
fi
84+
7285
## Buildpack detection
7386

7487
buildpacks=($buildpack_root/*)
@@ -87,18 +100,6 @@ if [[ -n "$BUILDPACK_URL" ]]; then
87100
committish="master"
88101
fi
89102

90-
if [[ -n "$SSH_KEY" ]]; then
91-
mkdir -p ~/.ssh/
92-
chmod 700 ~/.ssh/
93-
94-
echo $SSH_KEY | base64 -d > ~/.ssh/id_rsa
95-
chmod 400 ~/.ssh/id_rsa
96-
97-
echo 'StrictHostKeyChecking=no' > ~/.ssh/config
98-
chmod 600 ~/.ssh/config
99-
100-
fi
101-
102103
set +e
103104
git clone --branch "$committish" --depth=1 "$url" "$buildpack" &> /dev/null
104105
SHALLOW_CLONED=$?

0 commit comments

Comments
 (0)