Skip to content

Commit

Permalink
Include branch name in deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Nov 24, 2024
1 parent 8fa01f1 commit d19a653
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ jobs:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }} # SSH private key stored as a GitHub secret
SSH_WEB_PATH: ${{ secrets.SSH_WEB_PATH }}
BRANCH_NAME: ${{ github.ref_name }}
run: |
# Save the private key for SSH
mkdir -p ~/.ssh
echo "$SSH_KEY" > "~/.ssh/id_$SSH_USER"
chmod 600 "~/.ssh/id_$SSH_USER"
echo "${SSH_KEY}" > "~/.ssh/id_${SSH_USER}"
chmod 600 "~/.ssh/id_${SSH_USER}"
# Copy the artifact to the VPS
scp -i "~/.ssh/id_$SSH_USER" -P "$SSH_PORT" project.zip "$SSH_USER@$SSH_HOST:${SSH_WEB_PATH:.}"
# 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}"
# Connect to the VPS and unzip the project
ssh -i "~/.ssh/id_$SSH_USER" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" << 'EOF'
cd ${SSH_WEB_PATH:.}/
# Connect to the Remote and unzip the project
ssh -i "~/.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

0 comments on commit d19a653

Please sign in to comment.