42 lines
1.6 KiB
Bash
42 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Source the Discord webhook URL from a separate file
|
|
source "./discord_url"
|
|
|
|
# Fixed version to compare against
|
|
fixed_version="v1.20.2"
|
|
|
|
# Function to fetch version from custom Gitea API
|
|
function fetch_latest_sthopegit_version() {
|
|
curl -s 'https://git.sthope.dev/api/v1/version' | grep '"version":' | cut -d '"' -f 4
|
|
}
|
|
|
|
# Function to fetch latest Gitea version from GitHub API
|
|
function fetch_latest_gitea_version() {
|
|
curl -s "https://api.github.com/repos/go-gitea/gitea/releases/latest" | grep '"tag_name":' | cut -d '"' -f 4
|
|
}
|
|
|
|
# Function to send Discord message
|
|
function send_discord_message() {
|
|
message="$1"
|
|
curl -H "Content-Type: application/json" -X POST -d "{\"content\": \"$message\"}" "$DISCORD_WEBHOOK_URL"
|
|
}
|
|
|
|
# Fetch versions
|
|
sthopegit="v$(fetch_latest_sthopegit_version)"
|
|
gitea=$(fetch_latest_gitea_version)
|
|
|
|
# Compare versions and take actions
|
|
if [[ "${sthopegit}" == "${fixed_version}" && "${gitea}" == "${fixed_version}" ]]; then
|
|
# Do nothing, versions are the same
|
|
:
|
|
elif [[ "${sthopegit}" == "${fixed_version}" ]]; then
|
|
send_discord_message "Your version is the same as the fixed version, but the latest GitHub version is different."
|
|
send_discord_message "Latest version is ${gitea}"
|
|
elif [[ "${gitea}" == "${fixed_version}" ]]; then
|
|
# send_discord_message "The latest version from GitHub is the same as the fixed version, but your version is different."
|
|
:
|
|
else
|
|
send_discord_message "Your version and the latest version from GitHub are both different from the fixed version."
|
|
send_discord_message "Latest version is ${gitea}. And SthopeGit version is ${sthopegit}"
|
|
fi |