Skip to content

Commit 7f43a94

Browse files
committed
Add rebase CI
1 parent 01217ac commit 7f43a94

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/rebase.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
with:
22+
ref: ${{ env.BASE_BRANCH }}
23+
fetch-depth: 0
24+
25+
- run: |
26+
set -eux
27+
28+
base_branch=${{ env.BASE_BRANCH }}
29+
upstream_repo=${{ env.UPSTREAM_REPO }}
30+
upstream_branch=${{ env.UPSTREAM_BRANCH }}
31+
32+
git config user.email "[email protected]"
33+
git config user.name "GitHub CI"
34+
35+
git remote add upstream "${upstream_repo}"
36+
git fetch upstream
37+
git fetch origin
38+
git status
39+
git --version
40+
common_ancestor=$(git merge-base "${base_branch}" "upstream/${upstream_branch}")
41+
git format-patch "${common_ancestor}".."${base_branch}"
42+
git archive "${base_branch}" > backup.tar
43+
tar -rf backup.tar .git
44+
git reset --hard "upstream/${upstream_branch}"
45+
git am *.patch
46+
git push -f origin master-rebased
47+
48+
- if: always()
49+
name: Upload backup
50+
uses: actions/upload-artifact@v4
51+
with:
52+
if-no-files-found: error
53+
retention-days: 7
54+
name: backup
55+
path: |
56+
./backup.tar

0 commit comments

Comments
 (0)