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 1b3f00b commit a353b1b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/sync-branches-through-pr-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ jobs:
- name: Merge target branch into source branch, handle conflicts
run: |
git checkout -b ${{ steps.prepare.outputs.branch }} origin/${{ github.event.inputs.target }}
git merge --no-commit ${{ github.event.inputs.source }} || true
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=.*"
LINE_PATTERN="YOUR_PATTERN_HERE" # e.g., "SPECIAL_VAR=.*"
# Check if params.env has conflicts
if git ls-files -u | grep "components/odh-notebook-controller/config/base/params.env"; then
if git ls-files -u | grep "params.env"; then
# Resolve conflict by keeping the target branch's version for the specified line
TARGET_LINE=$(grep "$LINE_PATTERN" components/odh-notebook-controller/config/base/params.env) || true
TARGET_LINE=$(grep "$LINE_PATTERN" params.env) || true
if [ -n "$TARGET_LINE" ]; then
# Use target branch's line
Expand All @@ -56,7 +56,8 @@ jobs:
fi
# 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 }} with specified line preserved in params.env"
- name: Create pull request
Expand Down

0 comments on commit a353b1b

Please sign in to comment.