Skip to content

Commit

Permalink
Fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dhschall committed Jul 25, 2024
1 parent 35b58aa commit b68f7ca
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 25 deletions.
37 changes: 12 additions & 25 deletions .github/workflows/update-go-dep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,30 @@ 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: Checkout code into go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: '1.21'

- name: Check out code
uses: actions/checkout@v4
with:
ref: main
- 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: Find all go.mod files
shell: bash
run: |
PATHS=$(find . -type f -name go.mod -printf '%h ')
- name: Upgrade the Golang Dependencies for all mod files
id: detect-and-update
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@v6
with:
token: ${{ secrets.ENABLE_AUTOMERGE_TOKEN }}
branch: "upgrade-go-deps-on-main"
commit-message: "Upgrade go deps"
signoff: true
Expand Down
2 changes: 2 additions & 0 deletions utils/install_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ export PATH=$PATH:/usr/local/go/bin
sudo sh -c "echo 'export PATH=\$PATH:/usr/local/go/bin' >> /etc/profile"
sh -c "echo 'export PATH=\$PATH:/usr/local/go/bin' >> $HOME/.bashrc"

rm ${GO_BUILD}.tar.gz

echo "Installed: $(go version)"
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 b68f7ca

Please sign in to comment.