mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-07-01 04:22:08 +00:00
Update update-dependencies.yml
This commit is contained in:
parent
174f9c011a
commit
d065a50231
1 changed files with 69 additions and 11 deletions
80
.github/workflows/update-dependencies.yml
vendored
80
.github/workflows/update-dependencies.yml
vendored
|
@ -2,38 +2,91 @@ name: Update Go Dependencies
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * 1' # Запуск каждую неделю (понедельник в 00:00 UTC)
|
- cron: '0 0 * * 1' # Run weekly on Monday at 00:00 UTC
|
||||||
workflow_dispatch: # Позволяет запускать вручную
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write # Explicitly set permissions
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest # Use latest Ubuntu for better security
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
fetch-depth: 0 # Fetch all history for better change detection
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Clean Go module cache
|
|
||||||
run: go clean -modcache
|
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
- name: Update dependencies
|
cache: true # Enable Go module caching
|
||||||
|
|
||||||
|
- name: Clean Go module cache
|
||||||
run: |
|
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 mod tidy
|
go clean -cache
|
||||||
|
go clean -testcache
|
||||||
|
|
||||||
|
- name: Update dependencies
|
||||||
|
id: update
|
||||||
|
run: |
|
||||||
|
# Create error log file
|
||||||
|
touch update_errors.log
|
||||||
|
|
||||||
|
# Update dependencies with error handling
|
||||||
|
{
|
||||||
|
# List current versions
|
||||||
|
echo "Current versions:" > dependency_changes.txt
|
||||||
|
go list -m all >> dependency_changes.txt
|
||||||
|
|
||||||
|
# Update dependencies, excluding specific packages
|
||||||
|
go get -u $(go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | \
|
||||||
|
grep -v 'gvisor.dev/gvisor')
|
||||||
|
|
||||||
|
# Tidy and verify modules
|
||||||
|
go mod tidy
|
||||||
|
go mod verify
|
||||||
|
|
||||||
|
# List updated versions
|
||||||
|
echo -e "\nUpdated versions:" >> dependency_changes.txt
|
||||||
|
go list -m all >> dependency_changes.txt
|
||||||
|
|
||||||
|
} 2>update_errors.log || {
|
||||||
|
echo "::error::Failed to update dependencies"
|
||||||
|
cat update_errors.log
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Validate build
|
||||||
|
run: |
|
||||||
|
# Verify the project still builds
|
||||||
|
go build ./... || {
|
||||||
|
echo "::error::Build validation failed after dependency updates"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run tests if they exist
|
||||||
|
if [ -n "$(go list ./... | grep -v vendor)" ]; then
|
||||||
|
go test ./... -race || {
|
||||||
|
echo "::error::Tests failed after dependency updates"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Check for changes
|
- name: Check for changes
|
||||||
|
id: check
|
||||||
run: |
|
run: |
|
||||||
if ! git diff --exit-code go.mod go.sum; then
|
if ! git diff --exit-code go.mod go.sum; then
|
||||||
echo "changes=true" >> $GITHUB_ENV
|
echo "changes=true" >> $GITHUB_ENV
|
||||||
|
echo "Changes detected in dependencies"
|
||||||
else
|
else
|
||||||
echo "changes=false" >> $GITHUB_ENV
|
echo "changes=false" >> $GITHUB_ENV
|
||||||
|
echo "No dependency changes needed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
|
@ -44,3 +97,8 @@ jobs:
|
||||||
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 }}
|
git push origin ${{ github.ref }}
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
rm -f update_errors.log dependency_changes.txt
|
||||||
|
|
Loading…
Reference in a new issue