Skip to content

Commit a9020db

Browse files
authored
CI - Release branch check auto-changes base branch (#298)
## Description of Changes Instead of our CI failing and telling the user that a PR should be based on `master`, we automatically change the base branch to `master`. ## API No code changes. ## Requires SpacetimeDB PRs None ## Testsuite SpacetimeDB branch name: master ## Testing - [x] See below, where the new CI changed the base branch of this PR! - [x] On this test PR, the base branch was not changed: #299 --------- Co-authored-by: Zeke Foppa <[email protected]>
1 parent cd73918 commit a9020db

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

.github/workflows/check-pr-base.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,29 @@ name: Git tree checks
33
on:
44
pull_request:
55
types: [opened, edited, reopened, synchronize]
6-
merge_group:
7-
permissions: read-all
6+
7+
permissions:
8+
pull-requests: write
9+
contents: read
810

911
jobs:
1012
check_base_ref:
1113
name: Release branch restriction
1214
runs-on: ubuntu-latest
1315
steps:
14-
- id: not_based_on_master
16+
- name: Change base to master if needed
1517
if: |
1618
github.event_name == 'pull_request' &&
1719
github.event.pull_request.base.ref == 'release/latest' &&
1820
! startsWith(github.event.pull_request.head.ref, 'release/')
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1923
run: |
20-
echo 'Only `release/*` branches are allowed to merge into the release branch `release/latest`.'
21-
echo 'Maybe you want to change your PR base to `master`?'
22-
exit 1
24+
echo 'Updating PR '"#${{ github.event.pull_request.number }}"' to use base `master`'
25+
echo 'If you do want to release your changes directly by merging into `release/latest`, your branch must start with `release/`.'
26+
27+
curl -X PATCH \
28+
-H "Authorization: Bearer $GITHUB_TOKEN" \
29+
-H "Accept: application/vnd.github+json" \
30+
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \
31+
-d '{"base": "master"}'

0 commit comments

Comments
 (0)