From 773074def2bdaf28677992c8f4981556afa6c28a Mon Sep 17 00:00:00 2001 From: Kille135 <96112335+Kille135@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:51:56 +0300 Subject: [PATCH] Create sync.yml --- .github/workflows/sync.yml | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000000..29e8f78168 --- /dev/null +++ b/.github/workflows/sync.yml @@ -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"