forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 1.9 KB
/
rebase-upstream.yml
File metadata and controls
71 lines (61 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Rebase onto Upstream
on:
schedule:
- cron: '0 * * * *' # ⏰ Every hour
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
rebase:
runs-on: ubuntu-latest
steps:
- name: Checkout your forked main branch
uses: actions/checkout@v4
with:
ref: subshell-5
fetch-depth: 0 # Needed to rebase properly
- name: Set Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Add upstream remote
run: |
git remote add upstream https://github.com/denoland/deno.git
git fetch upstream
- name: Create backup branch (in case of conflict)
run: |
git branch backup-main-before-rebase
- name: Attempt rebase onto upstream/main
id: rebase
run: |
if git rebase upstream/main; then
echo "Rebase successful"
else
echo "Rebase conflict, aborting..."
git rebase --abort
git reset --hard backup-main-before-rebase
echo "REBASE_FAILED=true" >> $GITHUB_ENV
fi
- name: Check if HEAD is updated after rebase
id: head_check
run: |
CURRENT_HEAD=$(git rev-parse HEAD)
git fetch origin subshell-5
REMOTE_HEAD=$(git rev-parse origin/subshell-5)
if [ "$CURRENT_HEAD" != "$REMOTE_HEAD" ]; then
echo "HEAD_UPDATED=true" >> $GITHUB_ENV
else
echo "HEAD_UPDATED=false" >> $GITHUB_ENV
fi
- name: Push changes if rebase was successful
if: env.REBASE_FAILED != 'true'
run: |
git push origin subshell-5 --force
- name: Cleanup backup branch
if: always()
run: |
git branch -D backup-main-before-rebase || true