mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
Update update-dependencies.yml
This commit is contained in:
parent
58cda9d934
commit
20aca7bd6c
1 changed files with 70 additions and 25 deletions
93
.github/workflows/update-dependencies.yml
vendored
93
.github/workflows/update-dependencies.yml
vendored
|
@ -11,8 +11,7 @@ permissions:
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-latest # Используем последнюю версию Ubuntu
|
runs-on: ubuntu-latest # Используем последнюю версию Ubuntu
|
||||||
|
timeout-minutes: 30 # Таймаут для предотвращения зависания
|
||||||
timeout-minutes: 30 # Добавляем таймаут для предотвращения зависания
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
@ -21,13 +20,6 @@ jobs:
|
||||||
fetch-depth: 0 # Загружаем всю историю
|
fetch-depth: 0 # Загружаем всю историю
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version-file: go.mod
|
|
||||||
check-latest: true
|
|
||||||
cache: true # Включаем кэширование модулей
|
|
||||||
|
|
||||||
- name: Check go.mod exists
|
- name: Check go.mod exists
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f go.mod ]; then
|
if [ ! -f go.mod ]; then
|
||||||
|
@ -35,6 +27,13 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod # Используем версию из go.mod
|
||||||
|
check-latest: true
|
||||||
|
cache: true # Включаем кэширование модулей
|
||||||
|
|
||||||
- name: Clean Go module cache
|
- name: Clean Go module cache
|
||||||
run: |
|
run: |
|
||||||
go clean -modcache
|
go clean -modcache
|
||||||
|
@ -45,28 +44,68 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail # Строгий режим для bash
|
set -euo pipefail # Строгий режим для bash
|
||||||
|
|
||||||
echo "Updating Go dependencies..."
|
echo "::group::Updating Go dependencies"
|
||||||
|
|
||||||
# Обновляем зависимости с исключением gvisor без использования временных файлов
|
# Сохраняем текущие версии для сравнения
|
||||||
go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | \
|
go list -m all > before_update.txt
|
||||||
grep -v 'gvisor.dev/gvisor' | \
|
|
||||||
xargs -r go get -u
|
# Обновляем все зависимости кроме gvisor
|
||||||
|
modules_to_update=$(go list -f '{{if and (not .Main) (not .Indirect)}}{{.Path}}{{end}}' -m all | grep -v 'gvisor.dev/gvisor')
|
||||||
|
|
||||||
|
if [ -n "$modules_to_update" ]; then
|
||||||
|
echo "Updating modules: $modules_to_update"
|
||||||
|
echo "$modules_to_update" | xargs -r go get -u
|
||||||
|
else
|
||||||
|
echo "No direct modules to update"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Обновляем косвенные зависимости (кроме gvisor)
|
||||||
|
go get -u all
|
||||||
|
|
||||||
|
# Исключаем обновление gvisor (вернем его к исходной версии если было обновлено)
|
||||||
|
if go list -m gvisor.dev/gvisor &>/dev/null; then
|
||||||
|
original_version=$(grep "gvisor.dev/gvisor" go.mod | head -1 | awk '{print $2}')
|
||||||
|
if [ -n "$original_version" ]; then
|
||||||
|
echo "Restoring gvisor to original version: $original_version"
|
||||||
|
go get gvisor.dev/gvisor@$original_version
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Очистка и проверка
|
# Очистка и проверка
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go mod verify || exit 1
|
go mod verify || {
|
||||||
|
echo "Module verification failed"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Выводим изменения для лога
|
# Выводим изменения для лога
|
||||||
echo "Updated dependencies:"
|
go list -m all > after_update.txt
|
||||||
go list -m all
|
echo "Updates summary:"
|
||||||
|
diff -u before_update.txt after_update.txt || true
|
||||||
|
rm before_update.txt after_update.txt
|
||||||
|
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Test compilation
|
||||||
|
run: |
|
||||||
|
echo "::group::Testing compilation after updates"
|
||||||
|
# Проверяем, что проект компилируется после обновлений
|
||||||
|
go build -v ./... || {
|
||||||
|
echo "Compilation failed after dependency updates"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Check for changes
|
- name: Check for changes
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
if git diff --quiet go.mod go.sum; then
|
if git diff --quiet go.mod go.sum; then
|
||||||
echo "changes=false" >> $GITHUB_OUTPUT
|
echo "changes=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "No changes to dependencies detected"
|
||||||
else
|
else
|
||||||
echo "changes=true" >> $GITHUB_OUTPUT
|
echo "changes=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Changes detected in dependencies"
|
||||||
|
git diff --stat go.mod go.sum
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
|
@ -75,17 +114,22 @@ jobs:
|
||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
git add go.mod go.sum
|
# Создаем информативное сообщение коммита с перечнем обновлений
|
||||||
git commit -m "chore(deps): update Go dependencies
|
echo "Preparing commit message with dependency changes"
|
||||||
|
COMMIT_MSG="chore(deps): update Go dependencies\n\nAutomated update of Go dependencies excluding gvisor\n\nUpdated modules:"
|
||||||
|
git diff go.mod | grep -E "^\+\s+[a-z0-9]" | sed 's/^+[[:space:]]*/- /' > updated_modules.txt
|
||||||
|
UPDATES=$(cat updated_modules.txt)
|
||||||
|
|
||||||
Automated update of Go dependencies excluding gvisor"
|
git add go.mod go.sum
|
||||||
|
git commit -m "$(echo -e "$COMMIT_MSG\n$UPDATES")"
|
||||||
|
|
||||||
# Попытка push с повторами при ошибках
|
# Попытка push с повторами при ошибках
|
||||||
max_attempts=3
|
max_attempts=3
|
||||||
attempt=1
|
attempt=1
|
||||||
|
|
||||||
while [ $attempt -le $max_attempts ]; do
|
while [ $attempt -le $max_attempts ]; do
|
||||||
if git push origin ${{ github.ref }}; then
|
echo "Push attempt $attempt of $max_attempts"
|
||||||
|
if git push origin HEAD; then
|
||||||
echo "Successfully pushed changes on attempt $attempt"
|
echo "Successfully pushed changes on attempt $attempt"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
|
@ -93,9 +137,10 @@ jobs:
|
||||||
echo "Failed to push after $max_attempts attempts"
|
echo "Failed to push after $max_attempts attempts"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Push failed on attempt $attempt, retrying..."
|
echo "Push failed on attempt $attempt, retrying after pull and rebase..."
|
||||||
|
git pull --rebase origin $(git rev-parse --abbrev-ref HEAD)
|
||||||
attempt=$((attempt + 1))
|
attempt=$((attempt + 1))
|
||||||
git pull --rebase
|
sleep $((5 * attempt)) # Увеличиваем время ожидания с каждой попыткой
|
||||||
sleep 5
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
rm -f updated_modules.txt
|
||||||
|
|
Loading…
Reference in a new issue