Skip to content

Commit

Permalink
bugfix: support non-VERSION approach for KSM
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
  • Loading branch information
rexagod committed Jul 23, 2024
1 parent 3298e40 commit f05d45e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/merge-flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/merge-kube-state-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ jobs:
downstream: openshift/kube-state-metrics
sandbox: rhobs/kube-state-metrics
go-version: "1.20"
restore-upstream: CHANGELOG.md VERSION
restore-upstream: |
CHANGELOG.md .github/workflows/ .github/workflows/ 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 }}
Expand Down

0 comments on commit f05d45e

Please sign in to comment.