Skip to content

Commit

Permalink
Detect vendor and decode keys for bitbucket (wpengine#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
apmatthews authored Dec 15, 2022
1 parent a843a1a commit 40ff7fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ runs:
PHP_LINT: ${{ inputs.PHP_LINT }}
CACHE_CLEAR: ${{ inputs.CACHE_CLEAR }}
SCRIPT: ${{ inputs.SCRIPT }}
CICD_VENDOR: 'e2e_tests'
16 changes: 14 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ validate() {
: PHP_LINT="${PHP_LINT:="FALSE"}"
: CACHE_CLEAR="${CACHE_CLEAR:="TRUE"}"
: SCRIPT="${SCRIPT:=""}"
: CICD_VENDOR="${CICD_VENDOR:="wpe-cicd"}"
}

setup_env() {
Expand All @@ -27,6 +26,13 @@ setup_env() {
else echo "Failure: Missing environment variable..." && exit 1;
fi

if [[ -n ${GITHUB_ACTIONS} ]]; then
CICD_VENDOR="wpe_gha";
elif [[ -n ${BITBUCKET_BUILD_NUMBER} ]]; then
CICD_VENDOR="wpe_bb";
else CICD_VENDOR="wpe_cicd"
fi

echo "Deploying your code to:"
echo "${WPE_ENV_NAME}"

Expand Down Expand Up @@ -55,7 +61,13 @@ setup_ssh_dir() {

#Copy secret keys to container
WPE_SSHG_KEY_PRIVATE_PATH="${SSH_PATH}/wpe_id_rsa"
umask 077 ; echo "${WPE_SSHG_KEY_PRIVATE}" > "${WPE_SSHG_KEY_PRIVATE_PATH}"

if [ "${CICD_VENDOR}" == "wpe_bb" ]; then
# Only Bitbucket keys require base64 decode
umask 077 ; echo "${WPE_SSHG_KEY_PRIVATE}" | base64 -d > "${WPE_SSHG_KEY_PRIVATE_PATH}"
else umask 077 ; echo "${WPE_SSHG_KEY_PRIVATE}" > "${WPE_SSHG_KEY_PRIVATE_PATH}"
fi

chmod 600 "${WPE_SSHG_KEY_PRIVATE_PATH}"
#establish knownhosts
KNOWN_HOSTS_PATH="${SSH_PATH}/known_hosts"
Expand Down

0 comments on commit 40ff7fe

Please sign in to comment.