Skip to content

Commit 250fee6

Browse files
committed
Add rebase CI
1 parent 01217ac commit 250fee6

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/rebase.yaml

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

0 commit comments

Comments
 (0)