From 6d4987e06725fc70c1e1b8346cc5508fcd2da054 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 23 Mar 2025 21:11:51 -0400 Subject: [PATCH] Hardcode image name to codeberg.org/forgejo/forgejo in auto-update script --- ansible/templates/update-forgejo.sh.j2 | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ansible/templates/update-forgejo.sh.j2 b/ansible/templates/update-forgejo.sh.j2 index 5e3caaf..89111bf 100644 --- a/ansible/templates/update-forgejo.sh.j2 +++ b/ansible/templates/update-forgejo.sh.j2 @@ -77,11 +77,9 @@ get_current_image_details() { # Update Forgejo to the latest version update_forgejo() { local latest_version=$1 - local current_image=$(get_current_image_details) - local image_name=$(echo "$current_image" | cut -d':' -f1) + local image_name="codeberg.org/forgejo/forgejo" - log "Current image: $current_image" - log "Image name: $image_name" + log "Current image: $image_name:$(get_current_version)" # Check if Forgejo is running if ! is_forgejo_running; then @@ -93,12 +91,12 @@ update_forgejo() { backup_forgejo # 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" # Update the docker-compose file 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 log "Restarting Forgejo with the new version..." @@ -108,24 +106,28 @@ update_forgejo() { sleep 15 # 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" 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." exit 1 fi } +# Get current version +get_current_version() { + docker inspect --format='{% raw %}{{.Config.Image}}{% endraw %}' forgejo | cut -d':' -f2 +} + # Main execution log "=== Forgejo Auto-Update Script Started ===" # Get versions -CURRENT_IMAGE=$(get_current_image_details) +CURRENT_VERSION=$(get_current_version) LATEST_VERSION=$(get_latest_version) -CURRENT_VERSION=$(echo "$CURRENT_IMAGE" | cut -d':' -f2) log "Current version: $CURRENT_VERSION" log "Latest version: $LATEST_VERSION"