Hardcode image name to codeberg.org/forgejo/forgejo in auto-update script

This commit is contained in:
Your Name 2025-03-23 21:11:51 -04:00
parent 5941e13389
commit 6d4987e067

View file

@ -77,11 +77,9 @@ get_current_image_details() {
# Update Forgejo to the latest version # Update Forgejo to the latest version
update_forgejo() { update_forgejo() {
local latest_version=$1 local latest_version=$1
local current_image=$(get_current_image_details) local image_name="codeberg.org/forgejo/forgejo"
local image_name=$(echo "$current_image" | cut -d':' -f1)
log "Current image: $current_image" log "Current image: $image_name:$(get_current_version)"
log "Image name: $image_name"
# Check if Forgejo is running # Check if Forgejo is running
if ! is_forgejo_running; then if ! is_forgejo_running; then
@ -93,12 +91,12 @@ update_forgejo() {
backup_forgejo backup_forgejo
# Pull the latest image # Pull the latest image
log "Pulling the latest Forgejo image..." log "Pulling the latest Forgejo image... $image_name:$latest_version"
docker pull "$image_name:$latest_version" docker pull "$image_name:$latest_version"
# Update the docker-compose file with the new version # Update the docker-compose file with the new version
log "Updating docker-compose.yml with the new version..." log "Updating docker-compose.yml with the new version..."
sed -i "s|$image_name:[0-9.]*\+*|$image_name:$latest_version|g" "$COMPOSE_FILE" sed -i "s|codeberg.org/forgejo/forgejo:[0-9.]*\+*|$image_name:$latest_version|g" "$COMPOSE_FILE"
# Restart Forgejo with the new version # Restart Forgejo with the new version
log "Restarting Forgejo with the new version..." log "Restarting Forgejo with the new version..."
@ -108,24 +106,28 @@ update_forgejo() {
sleep 15 sleep 15
# Verify the update # Verify the update
NEW_IMAGE=$(get_current_image_details) NEW_VERSION=$(docker inspect --format='{% raw %}{{.Config.Image}}{% endraw %}' forgejo | cut -d':' -f2)
if [[ "$NEW_IMAGE" == *":$latest_version" ]]; then if [ "$NEW_VERSION" = "$latest_version" ]; then
log "Forgejo successfully updated to version $latest_version" log "Forgejo successfully updated to version $latest_version"
else else
log "ERROR: Update verification failed. Current image: $NEW_IMAGE, Expected version: $latest_version" log "ERROR: Update verification failed. Current version: $NEW_VERSION, Expected: $latest_version"
log "Please check the container logs for more information." log "Please check the container logs for more information."
exit 1 exit 1
fi fi
} }
# Get current version
get_current_version() {
docker inspect --format='{% raw %}{{.Config.Image}}{% endraw %}' forgejo | cut -d':' -f2
}
# Main execution # Main execution
log "=== Forgejo Auto-Update Script Started ===" log "=== Forgejo Auto-Update Script Started ==="
# Get versions # Get versions
CURRENT_IMAGE=$(get_current_image_details) CURRENT_VERSION=$(get_current_version)
LATEST_VERSION=$(get_latest_version) LATEST_VERSION=$(get_latest_version)
CURRENT_VERSION=$(echo "$CURRENT_IMAGE" | cut -d':' -f2)
log "Current version: $CURRENT_VERSION" log "Current version: $CURRENT_VERSION"
log "Latest version: $LATEST_VERSION" log "Latest version: $LATEST_VERSION"