Skip to content

Commit

Permalink
Use HOME variable
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Nov 24, 2024
1 parent 6844f58 commit 1b2b631
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,23 @@ jobs:
BRANCH_NAME: ${{ github.ref_name }}
run: |
#!/usr/bin/env bash
set -ex -o pipefail
# Save the private key for SSH
mkdir -pv ~/.ssh
echo "${SSH_KEY}" > "~/.ssh/id_${SSH_USER}"
chmod -v 400 "~/.ssh/id_${SSH_USER}"
mkdir -pv "${HOME}/.ssh"
echo "${SSH_KEY}" > "${HOME}/.ssh/id_${SSH_USER}"
chmod -v 400 "${HOME}/.ssh/id_${SSH_USER}"
# Copy the artifact to the Remote
scp -i "~/.ssh/id_${SSH_USER}" -P "${SSH_PORT}" project.zip "${SSH_USER}@${SSH_HOST}:${SSH_WEB_PATH}/${BRANCH_NAME}"
scp -i "${HOME}/.ssh/id_${SSH_USER}" -P "${SSH_PORT}" project.zip "${SSH_USER}@${SSH_HOST}:${SSH_WEB_PATH}/${BRANCH_NAME}"
# Connect to the Remote and unzip the project
ssh -i "~/.ssh/id_${SSH_USER}" -p "${SSH_PORT}" "${SSH_USER}@${SSH_HOST}" << EOF
ssh -i "${HOME}/.ssh/id_${SSH_USER}" -p "${SSH_PORT}" "${SSH_USER}@${SSH_HOST}" << EOF
mkdir -p ${SSH_WEB_PATH}/${BRANCH_NAME}
cd ${SSH_WEB_PATH}/${BRANCH_NAME}
unzip ./project.zip
rm ./project.zip
EOF
# Cleanup the secret
rm -rfv "~/.ssh/id_${SSH_USER}" "~/.ssh/id_${SSH_USER}.pub"
rm -rfv "${HOME}/.ssh/id_${SSH_USER}" "${HOME}/.ssh/id_${SSH_USER}.pub"

0 comments on commit 1b2b631

Please sign in to comment.