Hardcode image name to codeberg.org/forgejo/forgejo in auto-update script
This commit is contained in:
parent
5941e13389
commit
6d4987e067
1 changed files with 13 additions and 11 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue