Skip to content

Commit

Permalink
update-go-version: Don't add the go version if key is not in the work…
Browse files Browse the repository at this point in the history
…flow

If this script is run then all the workflow file have go version details
even the one which doesn't need. This PR first check if the workflow
file have go version key then only update it otherwise not.

- https://mikefarah.gitbook.io/yq/operators/has
  • Loading branch information
praveenkumar committed May 7, 2024
1 parent 6ee5d78 commit b49d820
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion update-go-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ go mod edit -go ${golang_base_version} tools/go.mod
sed -i "s,^\(FROM registry.ci.openshift.org/openshift/release:rhel-8-release-golang-\)1.[0-9]\+,\1${golang_base_version}," images/*/Dockerfile
sed -i "s,^FROM registry.access.redhat.com/ubi8/go-toolset:[.0-9]\+,FROM registry.access.redhat.com/ubi8/go-toolset:${golang_base_version}," images/*/Dockerfile
for f in .github/workflows/*.yml; do
yq eval --inplace ".jobs.build.strategy.matrix.go[0] = ${golang_base_version}" "$f";
if [ $(yq eval '.jobs.build.strategy.matrix | has("go")' "$f") == "true" ]; then
yq eval --inplace ".jobs.build.strategy.matrix.go[0] = ${golang_base_version}" "$f";
fi
done

0 comments on commit b49d820

Please sign in to comment.