From 9af75ed51b32a3b6f1079f88599e438d5974ca15 Mon Sep 17 00:00:00 2001
From: civisrom <167646351+civisrom@users.noreply.github.com>
Date: Sun, 9 Feb 2025 23:37:55 +0300
Subject: [PATCH] Update update-dependencies.yml

---
 .github/workflows/update-dependencies.yml | 53 +++++++++++++++++------
 1 file changed, 40 insertions(+), 13 deletions(-)

diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml
index 01d9483f..593f34b5 100644
--- a/.github/workflows/update-dependencies.yml
+++ b/.github/workflows/update-dependencies.yml
@@ -2,38 +2,65 @@ name: Update Go Dependencies
 
 on:
   schedule:
-    - cron: '0 0 * * 1'  # Запуск каждую неделю (понедельник в 00:00 UTC)
-  workflow_dispatch:  # Позволяет запускать вручную
+    - cron: '0 0 * * 1'  # Запуск каждую неделю в понедельник в 00:00 UTC
+  workflow_dispatch:      # Возможность ручного запуска
+
+permissions:
+  contents: write        # Явное указание разрешений
 
 jobs:
   update:
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-20.04  # Используем свежую Ubuntu
 
     steps:
       - name: Checkout repository
         uses: actions/checkout@v4
         with:
+          fetch-depth: 0    # Загружаем всю историю
           token: ${{ secrets.GITHUB_TOKEN }}
-          
-      - name: Clean Go module cache
-        run: go clean -modcache
-          
+
       - name: Setup Go
         uses: actions/setup-go@v5
         with:
           go-version-file: go.mod
-      
-      - name: Update dependencies
+          check-latest: true
+          cache: true       # Включаем кэширование модулей
+
+      - name: Clean Go module cache
         run: |
-          go get -u $(go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | grep -v 'gvisor.dev/gvisor')
+          go clean -modcache
+          go clean -cache
+
+      - name: Update dependencies
+        id: update
+        run: |
+          set -e  # Прерываем выполнение при ошибках
+          echo "Updating Go dependencies..."
+          
+          # Выводим текущие версии
+          echo "Current versions:"
+          go list -m all
+          
+          # Обновляем только объявленные зависимости
+          go get -u ./...
+          
+          # Приводим зависимости в порядок
           go mod tidy
+          go mod verify
+          
+          # Выводим обновленные версии
+          echo -e "\nUpdated versions:"
+          go list -m all
 
       - name: Check for changes
+        id: check
         run: |
-          if ! git diff --exit-code go.mod go.sum; then
-            echo "changes=true" >> $GITHUB_ENV
-          else
+          if git diff --quiet go.mod go.sum; then
+            echo "No dependency changes detected."
             echo "changes=false" >> $GITHUB_ENV
+          else
+            echo "Dependency changes detected."
+            echo "changes=true" >> $GITHUB_ENV
           fi
 
       - name: Commit and push changes