From 4b04efdf8942137e07bcc3b8040bb3e11b229bc3 Mon Sep 17 00:00:00 2001 From: Marco Baumgartner Date: Fri, 8 Dec 2023 13:16:19 +0100 Subject: [PATCH] feat: fork sync on releases --- .github/workflows/fork-sync.yml | 45 ++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/.github/workflows/fork-sync.yml b/.github/workflows/fork-sync.yml index e1acca335e81..e2b6cee71353 100644 --- a/.github/workflows/fork-sync.yml +++ b/.github/workflows/fork-sync.yml @@ -2,15 +2,48 @@ name: Fork Sync on: schedule: - - cron: '0 7 * * 1,4' - # scheduled at 07:00 every Monday and Thursday + - cron: '0 0 * * *' + # scheduled once a day at midnight workflow_dispatch: # click the button on Github repo! jobs: sync: runs-on: ubuntu-latest steps: - - uses: tgymnich/fork-sync@v1.9.0 - with: - base: main - head: main + - name: Checkout code + uses: actions/checkout@v2 + + - name: Fetch upstream changes + run: | + git remote add upstream https://github.com/ionic-team/stencil.git + git fetch upstream + + - name: Check for new release in fork + id: check_fork_release + run: | + FORK_RELEASE=$(git tag -l | sort -V | tail -n 1) + echo "Latest fork release: $FORK_RELEASE" + echo "::set-output name=fork_release_tag::$FORK_RELEASE" + + - name: Check for new release in upstream + id: check_upstream_release + run: | + UPSTREAM_RELEASE=$(git ls-remote --tags https://github.com/ionic-team/stencil.git | cut -d '/' -f 3 | sort -V | tail -n 1) + echo "Latest upstream release: $UPSTREAM_RELEASE" + echo "::set-output name=upstream_release_tag::$UPSTREAM_RELEASE" + + - name: Create Pull Request + if: steps.check_fork_release.outputs.fork_release_tag != steps.check_upstream_release.outputs.upstream_release_tag + run: | + # Set up your branch for changes + git checkout -b sync-branch + + # Make changes, update files, etc. based on the new release + + # Commit and push changes to your forked repository + git add . + git commit -m "Sync with upstream release ${{ steps.check_upstream_release.outputs.upstream_release_tag }}" + git push origin sync-branch + + # Create Pull Request + gh pr create --base main --head sync-branch --title "Sync with upstream release ${{ steps.check_upstream_release.outputs.upstream_release_tag }}" --body "Syncing with the latest upstream release."