forked from attestantio/go-eth2-client
-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (91 loc) · 3.67 KB
/
sync-rebase.yml
File metadata and controls
104 lines (91 loc) · 3.67 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: sync-rebase
on:
schedule:
# scheduled at 07:00 every day
- cron: "0 7 * * *"
jobs:
sync_latest_from_upstream:
runs-on: ubuntu-latest
outputs:
has_new_commits: ${{ steps.sync.outputs.has_new_commits }}
steps:
- name: Checkout target repo
uses: actions/checkout@v4
with:
ref: master
- name: Configure Git user
run: |
git config --global user.name "obol-platform"
git config --global user.email "platform@obol.tech"
- name: Sync upstream changes
id: sync
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1
with:
target_sync_branch: master
target_repo_token: ${{ secrets.OBOL_PLATFORM_PAT }}
upstream_sync_branch: master
upstream_sync_repo: attestantio/go-eth2-client
rebase:
runs-on: ubuntu-latest
needs: sync_latest_from_upstream
if: needs.sync_latest_from_upstream.outputs.has_new_commits == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: obol
- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
echo "$GPG_PRIVATE_KEY" | base64 -d | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Configure Git user
run: |
git config --global user.name "obol-platform"
git config --global user.email "platform@obol.tech"
git config --global user.signingkey "$(gpg --list-secret-keys --keyid-format LONG platform@obol.tech | grep sec | awk '{print $2}' | cut -d'/' -f2)"
git config --global commit.gpgsign true
git config --global tag.gpgsign true
- name: Rebase branch obol
id: rebase
env:
GITHUB_TOKEN: ${{ secrets.OBOL_PLATFORM_PAT }}
run: |
echo "Rebasing branch obol on branch master"
git fetch
{
echo "RESULT<<EOF"
echo $(git rebase origin/master 2>&1)
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo "Rebase completed"
- name: Push changes
if: contains(steps.rebase.outputs.RESULT, 'Successfully rebased and updated')
env:
GITHUB_TOKEN: ${{ secrets.OBOL_PLATFORM_PAT }}
run: |
echo "Force pushing rebased branch"
git push --force-with-lease origin obol
echo "Push successful 🚀"
- name: Rebase failed error
if: (contains(steps.rebase.outputs.RESULT, 'error:') || contains(steps.rebase.outputs.RESULT, 'fatal:')) && !contains(steps.rebase.outputs.RESULT, 'Merge conflict in')
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: dev-stack-releases
SLACK_COLOR: eb3d2c #red
SLACK_ICON: https://obol.org/ObolIcon.png?ref=blog.obol.org
SLACK_MESSAGE: "Failed to rebase branch obol on newly synced branch master due to error: ${{steps.rebase.outputs.RESULT}}"
SLACK_TITLE: "go-eth2-client rebase failed - error"
SLACK_WEBHOOK: ${{ secrets.SLACK_DEV_STACK_RELEASES_WEBHOOK }}
- name: Rebase failed conflict
if: contains(steps.rebase.outputs.RESULT, 'Merge conflict in')
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: dev-stack-releases
SLACK_COLOR: ecc926 #yellow
SLACK_ICON: https://obol.org/ObolIcon.png?ref=blog.obol.org
SLACK_MESSAGE: "Failed to rebase branch obol on newly synced branch master due to conflicts"
SLACK_TITLE: "go-eth2-client rebase failed - conflicts"
SLACK_WEBHOOK: ${{ secrets.SLACK_DEV_STACK_RELEASES_WEBHOOK }}