Skip to content

Commit 59b2180

Browse files
Fix opal-plus sync workflow: replace rebase with merge (#891)
The rebase-based sync was broken — rebase rewrites history, causing regular push to be rejected (fetch first). Replaced with a merge-based approach that preserves opal-plus customizations and only brings in new upstream changes incrementally. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cfcc05c commit 59b2180

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

.github/workflows/sync_opal_plus.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,65 @@ jobs:
2828
uses: actions/checkout@v4
2929
with:
3030
repository: permitio/opal
31-
ref: ${{ github.ref_name }}
31+
ref: master
3232
path: opal
33-
fetch-depth: 0
3433

3534
- name: Checkout permitio/opal-plus repository
3635
uses: actions/checkout@v4
3736
with:
3837
repository: permitio/opal-plus
3938
path: opal-plus
4039
token: ${{ steps.get_workflow_token.outputs.token }}
40+
fetch-depth: 0
4141

42-
- name: Create public-${{ github.ref_name }} branch in opal repository
43-
working-directory: opal
44-
run: |
45-
git checkout -b public-${{ github.ref_name }}
46-
47-
- name: Rebase opal-plus/public-${{ github.ref_name }} onto opal/${{ github.ref_name }}
42+
- name: Merge opal/master into public-master
4843
working-directory: opal-plus
4944
run: |
5045
git remote add opal ../opal
51-
git fetch opal
52-
git checkout public-${{ github.ref_name }}
53-
git rebase opal/${{ github.ref_name }}
46+
git fetch opal master
47+
48+
# Start from opal-plus/master so customizations are preserved
49+
if git rev-parse --verify origin/public-master >/dev/null 2>&1; then
50+
git checkout public-master
51+
else
52+
git checkout -b public-master master
53+
fi
54+
55+
# Merge upstream opal changes — fail the workflow if there are conflicts
56+
# so they can be resolved manually
57+
git merge opal/master --no-edit \
58+
-m "Merge opal/master ($(git rev-parse --short opal/master)) into public-master"
5459
55-
- name: Push changes to opal-plus/public-${{ github.ref_name }} branch
60+
- name: Push public-master branch
5661
working-directory: opal-plus
5762
run: |
58-
git push origin public-${{ github.ref_name }}
63+
git push origin public-master
5964
60-
- name: Create Pull Request for opal-plus
65+
- name: Create or update Pull Request
6166
working-directory: opal-plus
6267
run: |
6368
set -e
69+
70+
OPAL_SHORT_SHA=$(git rev-parse --short opal/master)
71+
6472
PR_NUMBER=$(gh pr list --repo permitio/opal-plus --base master --head public-master --json number --jq '.[0].number')
6573
if [ -n "$PR_NUMBER" ]; then
66-
echo "PR already exists: #$PR_NUMBER"
67-
gh pr edit "$PR_NUMBER" --repo permitio/opal-plus --add-reviewer "$GITHUB_ACTOR" || true
74+
echo "PR already exists: #$PR_NUMBER — updating."
75+
gh pr edit "$PR_NUMBER" --repo permitio/opal-plus \
76+
--body "Syncing opal/master (${OPAL_SHORT_SHA}) into opal-plus/master.
77+
78+
Review for conflicts with opal-plus customizations (banner, Docker image names, CI)." \
79+
--add-reviewer "$GITHUB_ACTOR" || true
6880
else
69-
gh pr create --repo permitio/opal-plus --assignee "$GITHUB_ACTOR" --reviewer "$GITHUB_ACTOR" --base master --head public-master --title "Sync changes from public OPAL repository" --body "This PR synchronizes changes from the public OPAL repository to the private OPAL Plus repository." || true
81+
gh pr create --repo permitio/opal-plus \
82+
--assignee "$GITHUB_ACTOR" \
83+
--reviewer "$GITHUB_ACTOR" \
84+
--base master \
85+
--head public-master \
86+
--title "Sync opal/master (${OPAL_SHORT_SHA}) into opal-plus" \
87+
--body "Syncing opal/master (${OPAL_SHORT_SHA}) into opal-plus/master.
88+
89+
Review for conflicts with opal-plus customizations (banner, Docker image names, CI)." || true
7090
echo "New PR created."
7191
fi
7292
shell: bash

0 commit comments

Comments
 (0)