Skip to content

Commit

Permalink
Fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dhschall authored May 9, 2024
1 parent 17cd355 commit cac245b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 24 deletions.
36 changes: 12 additions & 24 deletions .github/workflows/update-go-dep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions utils/update_go_dependencies.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cac245b

Please sign in to comment.