-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement workspace internal dependency updater
- Loading branch information
1 parent
f9ab362
commit f411abe
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Update Workspace dependencies | ||
description: Updates internal dependencies in a Go Workspace | ||
|
||
inputs: | ||
token: | ||
description: Github token | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
sudo DEBIAN_FRONTEND=noninteractive apt update | ||
sudo DEBIAN_FRONTEND=noninteractive apt install -y jq | ||
- name: Update workspace dependencies | ||
shell: bash | ||
run: ${{ github.action_path }}/update-workspace-dependencies.sh | ||
|
32 changes: 32 additions & 0 deletions
32
.github/actions/update-workspace-dependencies/update-workspace-dependencies.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
repo="github.com/${GITHUB_REPOSITORY}" | ||
|
||
# Gather all go modules | ||
modules=$(go work edit -json \ | ||
| jq -r '.Use | keys[] as $k | "\(.[$k].DiskPath)"' \ | ||
| sed $'s#\.\/##' \ | ||
) | ||
|
||
# Find internal dependencies | ||
for mod in ${modules} ; do | ||
cd "${mod}" | ||
echo "::group::Updating module ${mod}::" | ||
|
||
url="${repo}/${mod}" | ||
regex="s#${url} \(${repo}/[^@]\+\)@v.*#\1#p" | ||
dependencies=`go mod graph | sed -n "${regex}"` | ||
|
||
for dep in ${dependencies}; do | ||
go get "${dep}@main" | ||
done | ||
|
||
go mod tidy | ||
|
||
echo "Done" | ||
echo "::endgroup::" | ||
cd ~- | ||
done | ||
|
||
go work sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters