Skip to content

Commit b49d820

Browse files
committed
update-go-version: Don't add the go version if key is not in the workflow
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
1 parent 6ee5d78 commit b49d820

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

update-go-version.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ go mod edit -go ${golang_base_version} tools/go.mod
1414
sed -i "s,^\(FROM registry.ci.openshift.org/openshift/release:rhel-8-release-golang-\)1.[0-9]\+,\1${golang_base_version}," images/*/Dockerfile
1515
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
1616
for f in .github/workflows/*.yml; do
17-
yq eval --inplace ".jobs.build.strategy.matrix.go[0] = ${golang_base_version}" "$f";
17+
if [ $(yq eval '.jobs.build.strategy.matrix | has("go")' "$f") == "true" ]; then
18+
yq eval --inplace ".jobs.build.strategy.matrix.go[0] = ${golang_base_version}" "$f";
19+
fi
1820
done

0 commit comments

Comments
 (0)