Skip to content

Commit e44a4bd

Browse files
authored
bug: fix target branch for OCP bundle PR (Mellanox#1182)
On tag event, a PR with new OCP bundle is created; its target branch should be: - _master_ for **beta** tags, - otherwise should be the **release branch**. This change fixes that.
2 parents 59141c4 + b831add commit e44a4bd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,18 @@ jobs:
109109
registry: ${{ env.REGISTRY }}
110110
username: ${{ secrets.NVCR_USERNAME }}
111111
password: ${{ secrets.NVCR_TOKEN }}
112-
- name: Determine version and tag
112+
- name: Determine version, tag, and base branch
113113
run: |
114114
git_tag=${{ github.ref_name }}
115115
echo VERSION_WITH_PREFIX=$git_tag >> $GITHUB_ENV
116116
echo VERSION_WITHOUT_PREFIX=${git_tag:1} >> $GITHUB_ENV # without the 'v' prefix
117+
if echo $git_tag | grep beta; then
118+
base_branch=$DEFAULT_BRANCH
119+
else
120+
v_major_minor=$(echo $git_tag | grep -Eo '^v[0-9]+\.[0-9]+')
121+
base_branch=$v_major_minor.x
122+
fi
123+
echo BASE_BRANCH=$base_branch >> $GITHUB_ENV
117124
- name: Lookup image digest
118125
run: |
119126
network_operator_digest=$(skopeo inspect docker://$REGISTRY/$IMAGE_NAME:$VERSION_WITH_PREFIX | jq -r .Digest)
@@ -145,7 +152,7 @@ jobs:
145152
git push -u origin $FEATURE_BRANCH
146153
gh pr create \
147154
--head $FEATURE_BRANCH \
148-
--base $DEFAULT_BRANCH \
155+
--base $BASE_BRANCH \
149156
--title "task: update bundle to $VERSION_WITH_PREFIX" \
150157
--body "Created by the *${{ github.job }}* job in [${{ github.repository }} OCP bundle CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
151158
- name: Determine if to send bundle to RedHat

0 commit comments

Comments
 (0)