Skip to content

Commit

Permalink
Update deploy.yml to deploy to multiple servers
Browse files Browse the repository at this point in the history
  • Loading branch information
WinG4merBR committed Jan 18, 2025
1 parent b24a5c8 commit cd9cd3f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
chmod +x ./gradlew
./gradlew :foxy:shadowJar --no-daemon
- name: Deploy JAR to Server
- name: Deploying Foxy to clusters
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SERVERS: ${{ secrets.SERVERS }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_TARGET: ${{ secrets.SSH_TARGET }}
Expand All @@ -36,8 +36,15 @@ jobs:
echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
scp -o StrictHostKeyChecking=no -P $SSH_PORT foxy/build/libs/Foxy-*.jar $SSH_USER@$SSH_HOST:$SSH_TARGET/
ssh -o StrictHostKeyChecking=no -p $SSH_PORT $SSH_USER@$SSH_HOST << EOF
echo "Deploy completed!"
EOF
IFS=',' read -r -a server_array <<< "$SERVERS"
for index in "${!server_array[@]}"; do
echo "Deploying to server $((index + 1)) of ${#server_array[@]}..."
SERVER=${server_array[$index]}
scp -o StrictHostKeyChecking=no -P $SSH_PORT foxy/build/libs/Foxy-*.jar $SSH_USER@$SERVER:$SSH_TARGET/ > /dev/null 2>&1
ssh -o StrictHostKeyChecking=no -p $SSH_PORT $SSH_USER@$SERVER > /dev/null 2>&1 << EOF
echo "Deploy completed on server $((index + 1))!"
EOF
done

0 comments on commit cd9cd3f

Please sign in to comment.