From cac245b3bac95a2e4cfb22a851d172e00a350707 Mon Sep 17 00:00:00 2001 From: David Schall Date: Thu, 9 May 2024 21:43:02 +0000 Subject: [PATCH] Fix workflow --- .github/workflows/update-go-dep.yml | 36 +++++++++----------------- utils/update_go_dependencies.sh | 40 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 24 deletions(-) create mode 100755 utils/update_go_dependencies.sh diff --git a/.github/workflows/update-go-dep.yml b/.github/workflows/update-go-dep.yml index 9e8a038a0..442a5be9a 100644 --- a/.github/workflows/update-go-dep.yml +++ b/.github/workflows/update-go-dep.yml @@ -11,43 +11,31 @@ jobs: update_golang_deps: name: Update Golang Dependencies runs-on: ubuntu-latest + env: + GOPRIVATE_KEY: ${{ secrets.XDT_REPO_ACCESS_KEY }} + GOPRIVATE: "github.com/ease-lab/vhive-xdt" steps: - - name: Set up Go - uses: actions/setup-go@v4 + - name: Setup Go + uses: actions/setup-go@v5 with: - go-version: 1.21 + go-version: '1.21' - - name: Check out code - uses: actions/checkout@v3 + - name: Checkout code into go module directory + uses: actions/checkout@v4 with: ref: main - - name: Find all go.mod files - run: | - PATHS=$(find . -type f -name go.mod -printf '%h ') + - run: git config --global url."https://ease-lab:$(echo $GOPRIVATE_KEY)@github.com/ease-lab/vhive-xdt".insteadOf "https://github.com/ease-lab/vhive-xdt" - - name: Upgrade the Golang Dependencies for all mod files - id: detect-and-update + - name: Find all go.mod files run: | - - for p in $PATHS; - do - - echo "Update dependencies in $p" - go get -u ./... - - output=$(git status -s) - if [ -z "${output}" ]; then - exit 0 - fi - - go mod tidy - done + ./utils/update_go_dependencies.sh - name: Create Pull Request uses: peter-evans/create-pull-request@v4 with: + token: ${{ secrets.ENABLE_AUTOMERGE_TOKEN }} branch: "upgrade-go-deps-on-main" commit-message: "Upgrade go deps" signoff: true diff --git a/utils/update_go_dependencies.sh b/utils/update_go_dependencies.sh new file mode 100755 index 000000000..a5ef9035e --- /dev/null +++ b/utils/update_go_dependencies.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# MIT License +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set -e + +PATHS=$(find . -type f -name go.mod -printf '%h ') + +for p in $PATHS; +do + + pushd $p + + echo "Update dependencies in $p" + go get -u ./... || true + + go mod tidy || true + + popd + +done \ No newline at end of file