Skip to content

Commit 156d11b

Browse files
committed
Add rebase CI
1 parent 01217ac commit 156d11b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/rebase.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Rebase against upstream
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
schedule:
8+
- cron: '15 3 * * *'
9+
10+
jobs:
11+
rebase:
12+
name: Rebase now!
13+
runs-on: ubuntu-latest
14+
env:
15+
BASE_BRANCH: release-ci
16+
UPSTREAM_REPO: https://github.com/haskell/cabal.git
17+
UPSTREAM_BRANCH: master
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
ref: ${{ env.BASE_BRANCH }}
22+
23+
- run: |
24+
set -eux
25+
26+
base_branch=${{ env.BASE_BRANCH }}
27+
upstream_repo=${{ env.UPSTREAM_REPO }}
28+
upstream_branch=${{ env.UPSTREAM_BRANCH }}
29+
30+
git remote add upstream "${upstream_repo}"
31+
git fetch upstream
32+
common_ancestor=$(git merge-base "${base_branch}" "upstream/${upstream_branch}")
33+
git format-patch "${common_ancestor}".."${base_branch}"
34+
git archive "${base_branch}" > backup.tar
35+
tar -rf backup.tar .git
36+
git am *.patch
37+
git push -f origin master-rebased
38+
39+
- if: always()
40+
name: Upload backup
41+
uses: actions/upload-artifact@v4
42+
with:
43+
if-no-files-found: error
44+
retention-days: 7
45+
name: backup
46+
path: |
47+
./backup.tar

0 commit comments

Comments
 (0)