-
-
Notifications
You must be signed in to change notification settings - Fork 19
48 lines (38 loc) · 1.39 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Continuous Integration
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Build JAR with Gradle
run: |
chmod +x ./gradlew
./gradlew :foxy:shadowJar --no-daemon
- name: Deploying Foxy to clusters
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SERVERS: ${{ secrets.SERVERS }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_TARGET: ${{ secrets.SSH_TARGET }}
run: |
mkdir -p ~/.ssh
echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
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 "echo 'Deploy completed on server $((index + 1))!'"
done