Skip to content

Commit a6e7aca

Browse files
committed
Bump prometheus-operator jsonnet pin in CMO alongside merge
Alongside the prometheus-operator merge job, derive the release branch from the upstream tag and update the jsonnet pin in CMO's jsonnetfile.json (scoped to only the prometheus-operator dependency). Skips if already on the latest release branch to avoid overlapping with the general jsonnet deps update workflow. Also exposes upstream-release as an output of merge-flow.yaml.
1 parent d8dd0e5 commit a6e7aca

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/cmo-make-targets.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ on:
1414
description: List of make targets to be executed sequentially.
1515
required: true
1616
type: string
17+
pre-run:
18+
description: Optional shell commands to run before make targets.
19+
required: false
20+
default: ''
21+
type: string
1722
secrets:
1823
cloner-app-id:
1924
description: Github ID of cloner app
@@ -44,6 +49,9 @@ jobs:
4449
- uses: actions/setup-go@v6
4550
with:
4651
go-version-file: go.mod
52+
- name: Pre-run commands
53+
if: ${{ inputs.pre-run != '' }}
54+
run: ${{ inputs.pre-run }}
4755
- name: Execute make targets - ${{ inputs.make-targets }}
4856
run: make ${{ inputs.make-targets }}
4957
- name: Ignore if change is only in jsonnetfile.lock.json

.github/workflows/merge-flow.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,17 @@ on:
6060
slack-webhook-url:
6161
description: Slack webhook URL to send notification
6262
required: true
63+
outputs:
64+
upstream-release:
65+
description: The latest upstream release tag (e.g. "v0.92.0")
66+
value: ${{ jobs.merge.outputs.upstream-release }}
6367

6468
jobs:
6569
merge:
6670
runs-on: ubuntu-latest
6771
name: Perform merge operation
72+
outputs:
73+
upstream-release: ${{ steps.upstream.outputs.release }}
6874
steps:
6975
- name: Get latest upstream tag
7076
id: upstream

.github/workflows/merge-prometheus-operator.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,74 @@ jobs:
3636
cloner-app-id: ${{ secrets.CLONER_APP_ID }}
3737
cloner-app-private-key: ${{ secrets.CLONER_APP_PRIVATE_KEY }}
3838
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
39+
40+
# Bump the prometheus-operator jsonnet branch pin in CMO so that CRD schemas
41+
# and other generated assets stay in sync with the upstream release.
42+
check-prometheus-operator-jsonnet-pin:
43+
needs: prometheus-operator-merge
44+
# Run even if the merge job fails (e.g. due to conflicts).
45+
if: always() && needs.prometheus-operator-merge.outputs.upstream-release != ''
46+
runs-on: ubuntu-latest
47+
outputs:
48+
release-branch: ${{ steps.resolve.outputs.release-branch }}
49+
should-update: ${{ steps.resolve.outputs.should-update }}
50+
steps:
51+
- uses: actions/checkout@v7
52+
with:
53+
repository: openshift/cluster-monitoring-operator
54+
ref: main
55+
sparse-checkout: jsonnet/jsonnetfile.json
56+
- name: Resolve release branch from upstream tag
57+
id: resolve
58+
env:
59+
UPSTREAM_TAG: ${{ needs.prometheus-operator-merge.outputs.upstream-release }}
60+
run: |
61+
# v0.92.0 -> release-0.92
62+
RELEASE_BRANCH="release-${UPSTREAM_TAG#v}" && RELEASE_BRANCH="${RELEASE_BRANCH%.*}"
63+
64+
CURRENT=$(jq -r --arg remote "https://github.com/prometheus-operator/prometheus-operator" \
65+
'(.dependencies[] | select(.source.git.remote == $remote)).version' \
66+
jsonnet/jsonnetfile.json)
67+
68+
echo "latest: $RELEASE_BRANCH, current: $CURRENT"
69+
echo "release-branch=$RELEASE_BRANCH" >> "$GITHUB_OUTPUT"
70+
71+
if [ "$CURRENT" = "$RELEASE_BRANCH" ]; then
72+
echo "should-update=false" >> "$GITHUB_OUTPUT"
73+
else
74+
echo "should-update=true" >> "$GITHUB_OUTPUT"
75+
fi
76+
77+
bump-prometheus-operator-jsonnet:
78+
needs: check-prometheus-operator-jsonnet-pin
79+
# Skip if already pinned to the same release branch; another workflow handles updates within the same pin.
80+
if: needs.check-prometheus-operator-jsonnet-pin.outputs.should-update == 'true'
81+
uses: ./.github/workflows/cmo-make-targets.yaml
82+
with:
83+
pre-run: |
84+
REMOTE="https://github.com/prometheus-operator/prometheus-operator"
85+
BRANCH="${{ needs.check-prometheus-operator-jsonnet-pin.outputs.release-branch }}"
86+
87+
jq --arg remote "$REMOTE" --arg branch "$BRANCH" \
88+
'(.dependencies[] | select(.source.git.remote == $remote)).version = $branch' \
89+
jsonnet/jsonnetfile.json > jsonnet/jsonnetfile.json.tmp
90+
91+
mv jsonnet/jsonnetfile.json.tmp jsonnet/jsonnetfile.json
92+
make-targets: update COMPONENTS=https://github.com/prometheus-operator/prometheus-operator/jsonnet/prometheus-operator generate
93+
pr-title: "[bot] Bump prometheus-operator jsonnet release branch to ${{ needs.check-prometheus-operator-jsonnet-pin.outputs.release-branch }}"
94+
pr-body: |
95+
## Description
96+
Updates the prometheus-operator jsonnet branch pin in
97+
[`jsonnet/jsonnetfile.json`](https://github.com/openshift/cluster-monitoring-operator/blob/main/jsonnet/jsonnetfile.json)
98+
to match the latest upstream release, and regenerates all
99+
assets including prometheus-operator CRDs YAMLs.
100+
101+
Note: the [downstream openshift/prometheus-operator](https://github.com/openshift/prometheus-operator/blob/main/VERSION)
102+
may still be on an older version.
103+
That is not necessarily a blocker for this PR.
104+
secrets:
105+
pr-app-id: ${{ secrets.APP_ID }}
106+
pr-app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
107+
cloner-app-id: ${{ secrets.CLONER_APP_ID }}
108+
cloner-app-private-key: ${{ secrets.CLONER_APP_PRIVATE_KEY }}
109+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)