From a51387cd59930a86c1ded66cf1ccf8a559e6389e Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Tue, 23 Jul 2024 14:47:46 +0530 Subject: [PATCH] bugfix: support non-VERSION approach for KSM Signed-off-by: Pranshu Srivastava --- .github/workflows/merge-flow.yaml | 8 ++++---- .github/workflows/merge-kube-state-metrics.yaml | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/merge-flow.yaml b/.github/workflows/merge-flow.yaml index 082eccf..56e65c5 100644 --- a/.github/workflows/merge-flow.yaml +++ b/.github/workflows/merge-flow.yaml @@ -44,7 +44,7 @@ on: default: '' type: string downstream-version-expression: - description: Expression to extract downstream version from downstream repo. + description: Expression to extract downstream version from downstream repo. Follows the https://www.npmjs.com/package/semver spec. required: false default: '' type: string @@ -88,14 +88,14 @@ jobs: DOWNSTREAM_VERSION=$(curl -sL "https://raw.githubusercontent.com/${{ inputs.downstream }}/${{ inputs.downstream-branch }}/VERSION") if [[ "${DOWNSTREAM_VERSION}" =~ ^$|"404: Not Found" ]]; then # Strip the trailing URL from the expression. - DOWNSTREAM_VERSION_SED=$(echo "${{ inputs.downstream-version-expression }}" | sed -e 's/\(http[^ ]*\).*$/\1/' -e 's/http[^ ]*$//') + DOWNSTREAM_VERSION_EXPRESSION=$(echo "${{ inputs.downstream-version-expression }}" | sed -e 's/\(http[^ ]*\).*$/\1/' -e 's/http[^ ]*$//') # Strip the leading sed command from the expression. DOWNSTREAM_VERSION_URL=$(echo "${{ inputs.downstream-version-expression }}" | sed -n 's/^.*\(http[^ ]*\).*$/\1/p') - if [ "${DOWNSTREAM_VERSION_SED}" == "" ] || [ "${DOWNSTREAM_VERSION_URL}" == "" ]; then + if [ "${DOWNSTREAM_VERSION_EXPRESSION}" == "" ] || [ "${DOWNSTREAM_VERSION_URL}" == "" ]; then echo "::error::downstream-version-expression is invalid" exit 1 fi - DOWNSTREAM_VERSION=$(curl --silent "${DOWNSTREAM_VERSION_URL}" | eval "${DOWNSTREAM_VERSION_SED}") + DOWNSTREAM_VERSION=$(curl --silent "${DOWNSTREAM_VERSION_URL}" | eval "${DOWNSTREAM_VERSION_EXPRESSION}") if ! [[ "${DOWNSTREAM_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "::error::downstream-version-expression is invalid" exit 1 diff --git a/.github/workflows/merge-kube-state-metrics.yaml b/.github/workflows/merge-kube-state-metrics.yaml index 6446df5..68e2a61 100644 --- a/.github/workflows/merge-kube-state-metrics.yaml +++ b/.github/workflows/merge-kube-state-metrics.yaml @@ -20,9 +20,12 @@ jobs: upstream: kubernetes/kube-state-metrics downstream: openshift/kube-state-metrics sandbox: rhobs/kube-state-metrics - go-version: "1.20" - restore-upstream: CHANGELOG.md VERSION + go-version: "1.22" + restore-upstream: | + CHANGELOG.md .github/ Dockerfile docs/ go.mod restore-downstream: OWNERS + downstream-version-expression: | + sed -n -E 's/^version: "*([0-9]+\.[0-9]+\.[0-9]+)"$/v\1/p' https://raw.githubusercontent.com/openshift/kube-state-metrics/main/data.yaml secrets: pr-app-id: ${{ secrets.APP_ID }} pr-app-private-key: ${{ secrets.APP_PRIVATE_KEY }}