Skip to content

Commit f2aab79

Browse files
authored
ci: add auto-rebase and conflict detection workflows (#6578)
* ci: add auto-rebase and conflict detection workflows - Add auto-rebase.yml: automatically rebases all open PRs onto latest master on every push, using peter-evans/rebase@v4 - Add conflict-check.yml: labels conflicting PRs with 'needs-rebase' and comments with rebase instructions, using eps1lon/actions-label-merge-conflict@v3 - Update PR template: add 'Allow edits from maintainers' checkbox - Update CONTRIBUTING.md: add 'Keeping Your PR Up-to-Date' section with rebase instructions and upstream setup guide * docs: clarify that 'Allow edits from maintainers' only affects the PR branch --------- Co-authored-by: Ashutosh Kumar <ashutoshx7@users.noreply.github.com>
1 parent b986ecf commit f2aab79

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

.github/PULL_REQUEST_TEMPLATE/generic.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ This PR fixes #
5656
- [ ] I have followed the project's coding style guidelines.
5757
- [ ] I have run `npm run lint` and `npx prettier --check .` with no errors.
5858
- [ ] I have addressed the code review feedback from the previous submission, if applicable.
59+
- [ ] I have enabled **"Allow edits from maintainers"** _(required for auto-rebase; this only affects the PR branch, not your fork)_.
5960

6061
## Additional Notes for Reviewers
6162

.github/workflows/auto-rebase.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Auto Rebase PRs
2+
3+
on:
4+
push:
5+
branches: [master]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
rebase:
14+
name: Auto-rebase all open PRs onto latest master
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: peter-evans/rebase@v4
18+
with:
19+
base: master
20+
exclude-labels: |
21+
no-rebase
22+
wip
23+
do-not-merge
24+
exclude-drafts: true
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Label Conflicting PRs
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request_target:
7+
types: [synchronize]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
check:
15+
name: Detect merge conflicts
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: eps1lon/actions-label-merge-conflict@v3
19+
with:
20+
dirtyLabel: "needs-rebase"
21+
repoToken: "${{ secrets.GITHUB_TOKEN }}"
22+
retryAfter: 120
23+
retryMax: 5
24+
continueOnMissingPermissions: true
25+
commentOnDirty: |
26+
**This PR has merge conflicts with `master`.**
27+
28+
Please rebase your branch:
29+
```bash
30+
# Add upstream remote (one-time setup)
31+
git remote add upstream https://github.com/sugarlabs/musicblocks.git
32+
33+
# Fetch latest master and rebase
34+
git fetch upstream
35+
git rebase upstream/master
36+
37+
# Resolve any conflicts, then:
38+
git push --force-with-lease origin YOUR_BRANCH
39+
```
40+
41+
> **Tip:** Enable "Allow edits from maintainers" on this PR so we can auto-rebase for you next time. This only grants access to your PR branch. Your fork's other branches are not affected.
42+
commentOnClean: |
43+
Merge conflicts resolved. Ready for review.

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,43 @@ Follow these steps when contributing:
160160
161161
7. Respond to review feedback and update your branch as needed.
162162
163+
### Keeping Your PR Up-to-Date
164+
165+
Our CI automatically rebases your PR onto the latest `master` whenever
166+
new changes are merged. For this to work on fork PRs, you **must** enable
167+
**"Allow edits from maintainers"** when creating your PR.
168+
169+
> **Note:** This checkbox only grants maintainers push access to the
170+
> _specific branch_ associated with your PR. It does **not** affect
171+
> your fork's other branches or settings.
172+
173+
If your PR develops merge conflicts that can't be auto-resolved, our bot
174+
will label it with `needs-rebase` and comment with step-by-step rebase
175+
instructions.
176+
177+
**Manual rebase (if needed):**
178+
179+
```bash
180+
# Add the upstream remote (one-time setup)
181+
git remote add upstream https://github.com/sugarlabs/musicblocks.git
182+
183+
# Fetch the latest changes and rebase
184+
git fetch upstream
185+
git rebase upstream/master
186+
187+
# Resolve any conflicts in your editor, then:
188+
git add .
189+
git rebase --continue
190+
191+
# Push the updated branch
192+
git push --force-with-lease origin your-branch-name
193+
```
194+
195+
> **Tip:** Enable **"Allow edits from maintainers"** on your PR so
196+
> maintainers and our automation can keep your branch current. This
197+
> setting only applies to the PR branch. Your other branches and
198+
> fork settings are not affected.
199+
163200
### After your PR is merged
164201

165202
Please note that production deployments of Music Blocks are **manual**.

0 commit comments

Comments
 (0)