Update
This commit is contained in:
52
download-latest.sh
Normal file
52
download-latest.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- Configuration ---
|
||||
GITEA_URL="http://gitea.int.boger.local"
|
||||
OWNER="Workflows"
|
||||
REPO="gitea-runner-generic"
|
||||
TOKEN="<your-gitea-access-token-here>"
|
||||
ASSET_NAME="gitea-runner-generic.tar"
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "This script must be run as root or with sudo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /docker/gitea-runner-generic
|
||||
docker compose down
|
||||
|
||||
# --- Fetch latest release ---
|
||||
echo "Fetching latest release info..."
|
||||
release_json=$(curl -s -H "Authorization: token $TOKEN" \
|
||||
"$GITEA_URL/api/v1/repos/$OWNER/$REPO/releases/latest")
|
||||
|
||||
if [ -z "$release_json" ]; then
|
||||
echo "Failed to fetch release information."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Extract asset URL ---
|
||||
if [ -z "$ASSET_NAME" ]; then
|
||||
asset_url=$(echo "$release_json" | jq -r '.assets[0].browser_download_url')
|
||||
else
|
||||
asset_url=$(echo "$release_json" | jq -r --arg NAME "$ASSET_NAME" '.assets[] | select(.name==$NAME) | .browser_download_url')
|
||||
fi
|
||||
|
||||
if [ -z "$asset_url" ] || [ "$asset_url" == "null" ]; then
|
||||
echo "Asset not found in the latest release."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Download asset ---
|
||||
echo "Downloading asset from: $asset_url"
|
||||
curl -L -H "Authorization: token $TOKEN" -o "$(basename $asset_url)" "$asset_url"
|
||||
|
||||
echo "Download completed: $(basename $asset_url). Importing..."
|
||||
|
||||
docker image rm gitea-runner-generic:latest
|
||||
|
||||
docker load --input $ASSET_NAME
|
||||
|
||||
rm $ASSET_NAME
|
||||
|
||||
docker compose up -d
|
||||
Reference in New Issue
Block a user