From 65a548ed980057d73f35447d69505812d75ff06f Mon Sep 17 00:00:00 2001 From: dan-mm Date: Thu, 27 Jul 2023 15:00:52 +0200 Subject: [PATCH] added update_fork workflow, turned off update-sh.yml for pushes to master --- .github/workflows/update-sh.yml | 10 ++++---- .github/workflows/update_fork.yml | 39 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/update_fork.yml diff --git a/.github/workflows/update-sh.yml b/.github/workflows/update-sh.yml index 4e03239a..d1bf7c89 100644 --- a/.github/workflows/update-sh.yml +++ b/.github/workflows/update-sh.yml @@ -1,11 +1,11 @@ name: update.sh on: - push: - branches: - - master - schedule: - - cron: '15 0 * * *' + # push: + # branches: + # - master + # schedule: + # - cron: '15 0 * * *' workflow_dispatch: jobs: diff --git a/.github/workflows/update_fork.yml b/.github/workflows/update_fork.yml new file mode 100644 index 00000000..4dd56a6c --- /dev/null +++ b/.github/workflows/update_fork.yml @@ -0,0 +1,39 @@ +name: Sync Fork with Upstream +on: + schedule: + - cron: "30 23 * * *" + workflow_dispatch: + +permissions: + contents: write + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Git user + run: | + git config --global user.name "Dan Mateas" + git config --global user.email "dan@green-coding.berlin" + + - name: Add remote repository + run: | + g + git fetch upstream + + - name: Check for updates + run: | + CHANGES=$(git rev-list HEAD..upstream/master --count) + if [ "$CHANGES" -gt 0 ]; then + echo "Updating fork..." + git checkout master + git merge upstream/master + git push + else + echo "No updates from the original repository." + fi