(update) fix: sed
(update) fix: deploy script (update) ci: use java 21 (update) ci: update gradle version (update) ci: remove branch filter
This commit is contained in:
4 files changed
+16
-79
No files matched your search
@@ -10,7 +10,7 @@ name: Deploy to server
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master", "rev/1.21.6" ]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
if: github.event_name == 'schedule' || startsWith(github.event.head_commit.message, '(update)')
|
if: github.event_name == 'schedule' || startsWith(github.event.head_commit.message, '(update)')
|
||||||
@@ -28,11 +28,10 @@ jobs:
|
|||||||
|
|
||||||
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
|
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
|
||||||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
|
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
|
||||||
- name: Setup Gradle 8.10
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v4
|
||||||
with:
|
with:
|
||||||
gradle-version: "8.10" # Quotes required to prevent YAML converting to number
|
gradle-version: '8.12'
|
||||||
|
|
||||||
- name: Build with Gradle Wrapper
|
- name: Build with Gradle Wrapper
|
||||||
run: gradle remapJar
|
run: gradle remapJar
|
||||||
- name: Install JQ
|
- name: Install JQ
|
||||||
@@ -47,5 +46,4 @@ jobs:
|
|||||||
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
|
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
|
||||||
run: |
|
run: |
|
||||||
cd scripts
|
cd scripts
|
||||||
chmod +x ./special_curl
|
|
||||||
sh ./update.sh
|
sh ./update.sh
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Function to get IP address of a domain
|
|
||||||
get_ip() {
|
|
||||||
local domain=$1
|
|
||||||
# Get IP address (first one found) for the domain
|
|
||||||
dig +short "$domain" | head -n 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if a URL is provided
|
|
||||||
if [ "$#" -lt 1 ]; then
|
|
||||||
echo "Usage: $0 <url> [curl options...]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Extract the URL
|
|
||||||
url="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
# Define the fixed domain for --resolve
|
|
||||||
fixed_domain="gov.cn"
|
|
||||||
|
|
||||||
# Parse the URL
|
|
||||||
protocol=$(echo "$url" | awk -F:// '{print $1}')
|
|
||||||
original_domain_port=$(echo "$url" | awk -F:// '{print $2}' | awk -F/ '{print $1}')
|
|
||||||
path=$(echo "$url" | sed 's|^[^/]*/||')
|
|
||||||
|
|
||||||
# Extract port from the original URL
|
|
||||||
original_domain=$(echo "$original_domain_port" | awk -F: '{print $1}')
|
|
||||||
port=$(echo "$original_domain_port" | awk -F: '{print $2}')
|
|
||||||
|
|
||||||
# If port is not specified, default to 80 for HTTP or 443 for HTTPS
|
|
||||||
if [ -z "$port" ]; then
|
|
||||||
if [ "$protocol" == "http" ]; then
|
|
||||||
port=80
|
|
||||||
elif [ "$protocol" == "https" ]; then
|
|
||||||
port=443
|
|
||||||
else
|
|
||||||
echo "Unknown protocol. Please specify port in URL."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
ip=$(get_ip "$original_domain")
|
|
||||||
|
|
||||||
if [ -z "$ip" ]; then
|
|
||||||
echo "Could not resolve IP address for domain $fixed_domain"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Construct the --resolve argument
|
|
||||||
resolve_arg="-k --resolve $fixed_domain:$port:$ip"
|
|
||||||
|
|
||||||
# Replace the original domain with the fixed domain in the URL
|
|
||||||
modified_url=$(echo "$url" | sed "s/$original_domain/$fixed_domain/")
|
|
||||||
|
|
||||||
# Run curl with the resolve argument and any additional curl options
|
|
||||||
#echo "Running: curl $resolve_arg $@ $modified_url"
|
|
||||||
curl $resolve_arg "$@" "$modified_url"
|
|
||||||
|
|
||||||
+12
-13
@@ -1,7 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
exit 0
|
|
||||||
exit
|
|
||||||
export PATH="$PATH:$(pwd)"
|
export PATH="$PATH:$(pwd)"
|
||||||
UPLOAD="$UPLOAD_DIR/$(ls $UPLOAD_DIR | tr ' ' '\n' | grep -v "all")"
|
UPLOAD="$UPLOAD_DIR/$(ls $UPLOAD_DIR | tr ' ' '\n' | grep -v "all")"
|
||||||
|
|
||||||
@@ -10,43 +7,45 @@ if ! test -f "$UPLOAD"; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MOD=$(special_curl $API_ENDPOINT/api/client/servers/$SERVER_ID/files/list\?directory\=/mods -H "Authorization: Bearer $TOKEN" | jq -r ".data[] | .attributes.name" | grep "sfcraft")
|
MOD=$(curl $API_ENDPOINT/api/client/servers/$SERVER_ID/files/list\?directory\=/mods -H "Authorization: Bearer $TOKEN" | jq -r ".data[] | .attributes.name" | grep "sfcraft")
|
||||||
echo "Fetch: $MOD"
|
echo "Fetch: $MOD"
|
||||||
if [ -n "$MOD" ]; then
|
if [ -n "$MOD" ]; then
|
||||||
echo "Update target: $MOD"
|
echo "Update target: $MOD"
|
||||||
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/files/delete" -H "Content-Type: application/json" -H "Accept: application/json" -X POST -H "Authorization: Bearer $TOKEN" -d "{\"root\": \"/mods\", \"files\": [\"$MOD\"]}"
|
curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/files/delete" -H "Content-Type: application/json" -H "Accept: application/json" -X POST -H "Authorization: Bearer $TOKEN" -d "{\"root\": \"/mods\", \"files\": [\"$MOD\"]}"
|
||||||
echo "Deleted."
|
echo "Deleted."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Uploading $UPLOAD"
|
echo "Uploading $UPLOAD"
|
||||||
SIGNED_URL=$(special_curl $API_ENDPOINT/api/client/servers/$SERVER_ID/files/upload -H "Authorization: Bearer $TOKEN" | jq -r ".attributes.url")
|
SIGNED_URL=$(curl $API_ENDPOINT/api/client/servers/$SERVER_ID/files/upload -H "Authorization: Bearer $TOKEN" | jq -r ".attributes.url")
|
||||||
|
|
||||||
if [ -z "$SIGNED_URL" ]; then
|
if [ -z "$SIGNED_URL" ]; then
|
||||||
echo "!!! CANNOT FETCH SIGNED URL !!!"
|
echo "!!! CANNOT FETCH SIGNED URL !!!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
special_curl "$SIGNED_URL&directory=/mods" -X POST -F "files=@$UPLOAD"
|
SIGNED_URL=$(echo $SIGNED_URL | sed "s_http://192.168.1.75:32303_$API_ENDPOINT/api-1_")
|
||||||
|
|
||||||
|
curl "$SIGNED_URL&directory=/mods" -X POST -F "files=@$UPLOAD"
|
||||||
echo "Uploaded!"
|
echo "Uploaded!"
|
||||||
|
|
||||||
BROADCAST="Server is shutting down in 10s, please be ready."
|
BROADCAST="Server is shutting down in 10s, please be ready."
|
||||||
UPDATE_CONTENT_COMMAND="tellraw @a {\"text\":$(echo $COMMIT_AUTHOR: $COMMIT_MESSAGE | jq -Ra .),\"color\":\"aqua\"}"
|
UPDATE_CONTENT_COMMAND="tellraw @a {\"text\":$(echo $COMMIT_AUTHOR: $COMMIT_MESSAGE | jq -Ra .),\"color\":\"aqua\"}"
|
||||||
UPDATE_CONTENT_COMMAND=$(echo $UPDATE_CONTENT_COMMAND | jq -Ra .)
|
UPDATE_CONTENT_COMMAND=$(echo $UPDATE_CONTENT_COMMAND | jq -Ra .)
|
||||||
echo $UPDATE_CONTENT_COMMAND
|
echo $UPDATE_CONTENT_COMMAND
|
||||||
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/command" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d '{"command":"tellraw @a [{\"text\":\"< SFCRAFT UPDATE >\\n\",\"color\":\"aqua\"}]"}'
|
curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/command" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d '{"command":"tellraw @a [{\"text\":\"< SFCRAFT UPDATE >\\n\",\"color\":\"aqua\"}]"}'
|
||||||
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/command" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"command\":$UPDATE_CONTENT_COMMAND}"
|
curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/command" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"command\":$UPDATE_CONTENT_COMMAND}"
|
||||||
sleep 1s
|
sleep 1s
|
||||||
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/command" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"command\":\"say $BROADCAST\"}"
|
curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/command" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"command\":\"say $BROADCAST\"}"
|
||||||
echo "Broadcast is sent!"
|
echo "Broadcast is sent!"
|
||||||
sleep 10s
|
sleep 10s
|
||||||
|
|
||||||
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/power" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"signal\":\"stop\"}"
|
curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/power" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"signal\":\"stop\"}"
|
||||||
echo "STOP is sent!"
|
echo "STOP is sent!"
|
||||||
|
|
||||||
sleep 60s
|
sleep 60s
|
||||||
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/power" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"signal\":\"kill\"}"
|
curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/power" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"signal\":\"kill\"}"
|
||||||
echo "KILL is sent!"
|
echo "KILL is sent!"
|
||||||
|
|
||||||
sleep 15s
|
sleep 15s
|
||||||
special_curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/power" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"signal\":\"start\"}"
|
curl "$API_ENDPOINT/api/client/servers/$SERVER_ID/power" -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "{\"signal\":\"start\"}"
|
||||||
echo "START IS SENT"
|
echo "START IS SENT"
|
||||||
Reference in new issue
Block a user