Skip to content

Commit

Permalink
Update sync-branches-through-pr-2.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
atheo89 authored Nov 8, 2024
1 parent 28d854a commit a29eef1
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions .github/workflows/sync-branches-through-pr-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,41 @@ jobs:
git merge --no-commit origin/${{ github.event.inputs.source }} || true
# Define the line pattern to preserve in the target branch
LINE_PATTERN="odh-notebook-controller-image=quay.io/opendatahub/odh-notebook-controller:1.9-*" # e.g., "SPECIAL_VAR=.*"
line1="odh-notebook-controller-image=quay.io/opendatahub/odh-notebook-controller:1.9-*" # e.g., "SPECIAL_VAR=.*"
line2="odh-kf-notebook-controller-image=quay.io/opendatahub/kubeflow-notebook-controller:1.9-**" # e.g., "SPECIAL_VAR=.*"
line3="KF_TAG ?= 1.9-**" # e.g., "SPECIAL_VAR=.*"
#components/odh-notebook-controller/Makefile
#components/odh-notebook-controller/config/base/params.env
# Resolve conflict by keeping the target branch's version for the specified line
TARGET_LINE1=$(grep "$line1" components/notebook-controller/config/overlays/openshift/params.env) || true
if [ -n "$TARGET_LINE1" ]; then
# Use target branch's line
sed -i "s|$LINE_PATTERN|$TARGET_LINE|" components/notebook-controller/config/overlays/openshift/params.env
fi
git add components/notebook-controller/config/overlays/openshift/params.env
# Resolve conflict by keeping the target branch's version for the specified line
TARGET_LINE2=$(grep "$line1" components/notebook-controller/config/overlays/openshift/params.env) || true
if [ -n "$TARGET_LINE1" ]; then
# Use target branch's line
sed -i "s|$LINE_PATTERN|$TARGET_LINE|" components/notebook-controller/config/overlays/openshift/params.env
fi
git add components/notebook-controller/config/overlays/openshift/params.env
# Check if params.env has conflicts
if git ls-files -u | grep "components/notebook-controller/config/overlays/openshift/params.env"; then
# Resolve conflict by keeping the target branch's version for the specified line
TARGET_LINE=$(grep "$LINE_PATTERN" params.env) || true
if [ -n "$TARGET_LINE" ]; then
# Use target branch's line
sed -i "s|$LINE_PATTERN|$TARGET_LINE|" components/notebook-controller/config/overlays/openshift/params.env
fi
git add components/notebook-controller/config/overlays/openshift/params.env
TARGET_LINE1=$(grep "$line1" components/notebook-controller/config/overlays/openshift/params.env) || true
if [ -n "$TARGET_LINE1" ]; then
# Use target branch's line
sed -i "s|$LINE_PATTERN|$TARGET_LINE|" components/notebook-controller/config/overlays/openshift/params.env
fi
git add components/notebook-controller/config/overlays/openshift/params.env
# Commit the merge, resolving conflicts
git commit -m "Merge ${{ github.event.inputs.source }} into ${{ github.event.inputs.target }} with specified line preserved in params.env"
git commit -m "Merge ${{ github.event.inputs.source }} into ${{ github.event.inputs.target }} resolve conflicts"
- name: Create pull request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
Expand Down

0 comments on commit a29eef1

Please sign in to comment.