Refactor SSH connection steps in deployment workflow: Updated environment variable names for clarity and added logging for resolved configuration. Enhanced SSH connection commands to utilize the new variable names, improving maintainability and readability of the deployment process.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m56s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m56s
This commit is contained in:
@@ -10,34 +10,43 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
HOST: ${{ vars.PROD_HOST }}
|
||||
PORT: ${{ vars.PROD_PORT }}
|
||||
USER: ${{ vars.PROD_USER }}
|
||||
SSH_HOST: ${{ vars.PROD_HOST }}
|
||||
SSH_PORT: ${{ vars.PROD_PORT }}
|
||||
SSH_USER: ${{ vars.PROD_USER }}
|
||||
|
||||
steps:
|
||||
- name: Show resolved non-secret config
|
||||
run: |
|
||||
echo "SSH_HOST=$SSH_HOST"
|
||||
echo "SSH_PORT=$SSH_PORT"
|
||||
echo "SSH_USER=$SSH_USER"
|
||||
|
||||
- name: Prepare SSH
|
||||
run: |
|
||||
set -e
|
||||
mkdir -p ~/.ssh
|
||||
printf "%s" "${{ secrets.PROD_SSH_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
ssh-keyscan -p "$PORT" "$HOST" >> ~/.ssh/known_hosts
|
||||
ssh-keyscan -p "$SSH_PORT" "$SSH_HOST" >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Test SSH connection
|
||||
run: |
|
||||
set -e
|
||||
ssh -i ~/.ssh/id_ed25519 \
|
||||
-o StrictHostKeyChecking=no \
|
||||
-o BatchMode=yes \
|
||||
-o ConnectTimeout=10 \
|
||||
-p "$PORT" \
|
||||
"$USER@$HOST" \
|
||||
-p "$SSH_PORT" \
|
||||
"$SSH_USER@$SSH_HOST" \
|
||||
"echo SSH OK"
|
||||
|
||||
- name: Run blue-green deployment
|
||||
run: |
|
||||
set -e
|
||||
ssh -i ~/.ssh/id_ed25519 \
|
||||
-o StrictHostKeyChecking=no \
|
||||
-o BatchMode=yes \
|
||||
-o ConnectTimeout=10 \
|
||||
-p "$PORT" \
|
||||
"$USER@$HOST" \
|
||||
-p "$SSH_PORT" \
|
||||
"$SSH_USER@$SSH_HOST" \
|
||||
"/home/tsschulz/deploy-yourpart-bluegreen.sh"
|
||||
Reference in New Issue
Block a user