Skip to content

Commit 7761e8a

Browse files
committed
bug: fix target branch for ocp bundle PR
On tag event, CI push PR with updated ocp bundle. The target branch should be master for beta tag, otherwise should be the release branch. Signed-off-by: Fred Rolland <[email protected]>
1 parent 59141c4 commit 7761e8a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,35 @@ jobs:
130130
export CHANNELS=stable,$version_major_minor
131131
export DEFAULT_CHANNEL=$version_major_minor
132132
make bundle bundle-build bundle-push
133+
- name: Determine Target Branch
134+
shell: bash
135+
run: |
136+
set -e # Fail on errors
137+
set -x # Enable trace mode for debugging
138+
# Extract the tag name from GITHUB_REF
139+
TAG_NAME="${GITHUB_REF##*/}"
140+
echo "Extracted TAG_NAME: $TAG_NAME"
141+
if [[ "$TAG_NAME" =~ beta ]]; then
142+
echo "Detected 'beta' tag. Setting branch to 'master'."
143+
echo "TARGET_BRANCH=master" >> $GITHUB_ENV
144+
else
145+
# Match version tags like v24.10.0 or v24.10.0-rc.3
146+
if [[ "$TAG_NAME" =~ ^v([0-9]+\.[0-9]+)\. ]]; then
147+
RELEASE_BRANCH="v${BASH_REMATCH[1]}.x"
148+
echo "Parsed release branch: $RELEASE_BRANCH"
149+
echo "TARGET_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV
150+
else
151+
echo "Failed to parse tag name: $TAG_NAME"
152+
exit 1
153+
fi
154+
fi
155+
156+
# Confirm the TARGET_BRANCH value
157+
echo "Determined target branch: $TARGET_BRANCH"
133158
- name: Create PR with bundle to Network Operator
134159
env:
135160
FEATURE_BRANCH: update-ocp-bundle-to-${{ env.VERSION_WITH_PREFIX }}
161+
TARGET_BRANCH: ${{ env.TARGET_BRANCH }}
136162
run: |
137163
git config user.name nvidia-ci-cd
138164
git config user.email [email protected]
@@ -145,7 +171,7 @@ jobs:
145171
git push -u origin $FEATURE_BRANCH
146172
gh pr create \
147173
--head $FEATURE_BRANCH \
148-
--base $DEFAULT_BRANCH \
174+
--base $TARGET_BRANCH \
149175
--title "task: update bundle to $VERSION_WITH_PREFIX" \
150176
--body "Created by the *${{ github.job }}* job in [${{ github.repository }} OCP bundle CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
151177
- name: Determine if to send bundle to RedHat

0 commit comments

Comments
 (0)