mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-20 05:52:24 +00:00
Update update-dependencies.yml
This commit is contained in:
parent
89799d8d34
commit
adfb731318
1 changed files with 48 additions and 20 deletions
68
.github/workflows/update-dependencies.yml
vendored
68
.github/workflows/update-dependencies.yml
vendored
|
@ -10,7 +10,9 @@ permissions:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-20.04 # Используем свежую Ubuntu
|
runs-on: ubuntu-20.04 # Используем последнюю версию Ubuntu
|
||||||
|
|
||||||
|
timeout-minutes: 30 # Добавляем таймаут для предотвращения зависания
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
@ -26,6 +28,13 @@ jobs:
|
||||||
check-latest: true
|
check-latest: true
|
||||||
cache: true # Включаем кэширование модулей
|
cache: true # Включаем кэширование модулей
|
||||||
|
|
||||||
|
- name: Check go.mod exists
|
||||||
|
run: |
|
||||||
|
if [ ! -f go.mod ]; then
|
||||||
|
echo "Error: go.mod file not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Clean Go module cache
|
- name: Clean Go module cache
|
||||||
run: |
|
run: |
|
||||||
go clean -modcache
|
go clean -modcache
|
||||||
|
@ -34,40 +43,59 @@ jobs:
|
||||||
- name: Update dependencies
|
- name: Update dependencies
|
||||||
id: update
|
id: update
|
||||||
run: |
|
run: |
|
||||||
set -e # Прерываем выполнение при ошибках
|
set -euo pipefail # Строгий режим для bash
|
||||||
|
|
||||||
echo "Updating Go dependencies..."
|
echo "Updating Go dependencies..."
|
||||||
|
|
||||||
# Выводим текущие версии
|
# Обновляем зависимости с исключением gvisor без использования временных файлов
|
||||||
echo "Current versions:"
|
go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | \
|
||||||
go list -m all
|
grep -v 'gvisor.dev/gvisor' | \
|
||||||
|
xargs -r go get -u
|
||||||
# Обновляем только объявленные зависимости
|
|
||||||
go get -u $(go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | grep -v 'gvisor.dev/gvisor')
|
# Очистка и проверка
|
||||||
|
|
||||||
# Приводим зависимости в порядок
|
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go mod verify
|
go mod verify || exit 1
|
||||||
|
|
||||||
# Выводим обновленные версии
|
# Выводим изменения для лога
|
||||||
echo -e "\nUpdated versions:"
|
echo "Updated dependencies:"
|
||||||
go list -m all
|
go list -m all
|
||||||
|
|
||||||
- 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 "No dependency changes detected."
|
echo "changes=false" >> $GITHUB_OUTPUT
|
||||||
echo "changes=false" >> $GITHUB_ENV
|
|
||||||
else
|
else
|
||||||
echo "Dependency changes detected."
|
echo "changes=true" >> $GITHUB_OUTPUT
|
||||||
echo "changes=true" >> $GITHUB_ENV
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
if: env.changes == 'true'
|
if: steps.check.outputs.changes == 'true'
|
||||||
run: |
|
run: |
|
||||||
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 add go.mod go.sum
|
||||||
git commit -m "chore(deps): update Go dependencies"
|
git commit -m "chore(deps): update Go dependencies
|
||||||
git push origin ${{ github.ref }}
|
|
||||||
|
Automated update of Go dependencies excluding gvisor"
|
||||||
|
|
||||||
|
# Попытка push с повторами при ошибках
|
||||||
|
max_attempts=3
|
||||||
|
attempt=1
|
||||||
|
|
||||||
|
while [ $attempt -le $max_attempts ]; do
|
||||||
|
if git push origin ${{ github.ref }}; then
|
||||||
|
echo "Successfully pushed changes on attempt $attempt"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
if [ $attempt -eq $max_attempts ]; then
|
||||||
|
echo "Failed to push after $max_attempts attempts"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Push failed on attempt $attempt, retrying..."
|
||||||
|
attempt=$((attempt + 1))
|
||||||
|
git pull --rebase
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in a new issue