Skip to content

Commit

Permalink
Create sync.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Kille135 authored Apr 3, 2024
1 parent 3b085fb commit 773074d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Sync with Upstream

on:
branches: [ "atleta" ]
schedule:
- cron: "0 0 * * *" # Runs every day at midnight

jobs:
sync:
name: Sync with Upstream
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get latest release from upstream
id: get_latest_release
run: |
UPSTREAM_URL="https://github.com/blockscout/frontend"
UPSTREAM_BRANCH="main"
LATEST_RELEASE=$(git ls-remote --tags "$UPSTREAM_URL" | awk '{print $2}' | cut -d "/" -f 3 | sort -V | tail -n 1)
echo "::set-output name=latest_release::$LATEST_RELEASE"
- name: Check if there's a new release
id: check_release
run: |
LOCAL_BRANCH="atleta"
UPSTREAM_BRANCH="main"
if git merge-base --is-ancestor "$LOCAL_BRANCH" "$UPSTREAM_BRANCH"; then
echo "::set-output name=release_exists::false"
else
echo "::set-output name=release_exists::true"
fi
- name: Sync with upstream if a new release exists
if: steps.check_release.outputs.release_exists == 'true'
run: |
UPSTREAM_BRANCH="main"
git fetch upstream "$UPSTREAM_BRANCH"
git rebase "upstream/$UPSTREAM_BRANCH"
git push origin "$UPSTREAM_BRANCH"

0 comments on commit 773074d

Please sign in to comment.