Skip to content

Commit f153dde

Browse files
committed
Add rebase CI
1 parent 01217ac commit f153dde

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/rebase.yaml

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

0 commit comments

Comments
 (0)