Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions ssh-helper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ docker run -it --rm -v $(pwd):/keys/ codeship/ssh-helper prepare

The resulting file will be called `codeship.env`, and the value will be appended if that file already exists.

You can also override few variable to have custom keys location and names.

```shell
docker run -it --rm -v $(pwd):/keys/ --env BASE_FOLDER="/keys" --env KEY_FILE="/keys/my_codeship_deploy_key" --env ENV_FILE="/keys/my_codeship.env" codeship/ssh-helper prepare
```

## Write the Environment Variable Back to a File

During your Codeship Pro builds, you need to take the environment variable and write it back to a file, to pass to the `ssh` (or similar) commands.
Expand Down
8 changes: 4 additions & 4 deletions ssh-helper/ssh_helper.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
BASE_FOLDER="/keys"
KEY_FILE="${BASE_FOLDER}/codeship_deploy_key"
ENV_FILE="${BASE_FOLDER}/codeship.env"
[ -z "${BASE_FOLDER}" ] && BASE_FOLDER="/keys"
[ -z "${KEY_FILE}" ] && KEY_FILE="${BASE_FOLDER}/codeship_deploy_key"
[ -z "${ENV_FILE}" ] && ENV_FILE="${BASE_FOLDER}/codeship.env"

ACTION=$1 && shift

Expand All @@ -15,7 +15,7 @@ case "${ACTION}" in
;;
write)
mkdir -p "${BASE_FOLDER}/.ssh/"
printf "${PRIVATE_SSH_KEY}\n" >> "${BASE_FOLDER}/.ssh/id_rsa"
printf "${PRIVATE_SSH_KEY}\n" > "${BASE_FOLDER}/.ssh/id_rsa"
;;
*)
echo "Usage: $0 {generate|prepare|write}"
Expand Down