sync-rebase #342
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@34e114876b0b11c390a56381ad16ebd13914f8d5 # 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@1090e365224fc834e7e1de521c417ded2d6fcb53 # 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@34e114876b0b11c390a56381ad16ebd13914f8d5 # 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@e31e87e03dd19038e411e38ae27cbad084a90661 # 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@e31e87e03dd19038e411e38ae27cbad084a90661 # 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 }} |