-
Notifications
You must be signed in to change notification settings - Fork 19
72 lines (60 loc) · 2.1 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Compile & Deploy Gradle Jar
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: "17"
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Cache Gradle Dependencies
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}-
- name: Create build directory
run: mkdir -p build
- name: Gradle build
run: |
echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV
./gradlew build -PoutputDir=build
- name: Install JQ
run: sudo apt-get install jq
- name: Obtain Pterodactyl upload endpoint
run: |
response=$(curl "https://${{ vars.PTERO_HOST }}/api/client/servers/${{ vars.PTERO_SERVER_ID }}/files/upload" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${{ secrets.PTERO_API_KEY }}' \
-X GET)
url=$(echo "$response" | jq -r .attributes.url)
echo "URL=$url" >> $GITHUB_ENV
- name: Upload jar to Pterodactyl upload endpoint
run: |
echo $URL
echo $REPO_NAME
file=$(ls build/libs/$REPO_NAME.jar)
curl "$URL" \
-H 'Content-Type: multipart/form-data' \
-F "files=@$file" \
-X POST
- name: Restart Pterodactyl server
run: |
curl "https://${{ vars.PTERO_HOST }}/api/client/servers/${{ vars.PTERO_SERVER_ID }}/power" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${{ secrets.PTERO_API_KEY }}' \
-X POST \
-d '{
"signal": "restart"
}'