From ed01add6c58d2a8885078c589db38a882c51be78 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Tue, 21 Jun 2022 17:18:44 +0200 Subject: [PATCH 1/2] CI: Create workflow to rebase this fork to the latest upstream tag This workflow runs daily and opens a PR is there is a new tag available upstream, to sync it to that tag. --- .github/workflows/upstream-rebase.yml | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/upstream-rebase.yml diff --git a/.github/workflows/upstream-rebase.yml b/.github/workflows/upstream-rebase.yml new file mode 100644 index 0000000000..de29481872 --- /dev/null +++ b/.github/workflows/upstream-rebase.yml @@ -0,0 +1,36 @@ +name: "Rebase fork from upstream" +on: + schedule: + - cron: '0 8 * * *' # Every day on 8:00 UTC + pull_request: + paths: + - '.github/workflows/upstream-rebase.yml' + push: + paths: + - '.github/workflows/upstream-rebase.yml' + workflow_dispatch: + +jobs: + upstream-rebase: + runs-on: ubuntu-latest + steps: + # Checkout this repo + - uses: actions/checkout@v3 + # Get the latest version tag from the upstream + - run: git remote add upstream https://github.com/ERGO-Code/HiGHS.git + - run: git fetch upstream + - run: | + echo "latestTag=$(git tag -l --sort -version:refname | head -n 1)" >> $GITHUB_ENV + echo "$latestTag" + # Rebase from the main branch to the latest tag + - run: git fetch origin + - run: git checkout main + - run: git rebase upstream/$latestTag + - run: git push -f origin main + # Create a Pull request to pull the new tag into the main branch + - uses: peter-evans/create-pull-request@v4 + with: + title: "Rebase fork from upstream to $latestTag" + base: main + branch: upstream-rebase + commit-message: "[Bot] Rebase fork from upstream to $latestTag" From e146f298eeed55978cca5018efd4f8c7fa5d9b05 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Wed, 22 Jun 2022 12:09:22 +0200 Subject: [PATCH 2/2] CI: Only run upstream rebase action only unscheduled on forks Prevent the action from running (daily) on forks, by requiring the action to be either run on the scipy/HiGHS repo or be triggered by something else than the schedule. This way daily jobs won't run on forks, but maintenance can still be tested there. --- .github/workflows/upstream-rebase.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/upstream-rebase.yml b/.github/workflows/upstream-rebase.yml index de29481872..d7cc88f122 100644 --- a/.github/workflows/upstream-rebase.yml +++ b/.github/workflows/upstream-rebase.yml @@ -12,6 +12,9 @@ on: jobs: upstream-rebase: + # Only run if either on the scipy/HiGHS repo or if the event is not scheduled + # This prevents running scheduled jobs on forks + if: github.repository == 'scipy/HiGHS' || github.event_name != 'schedule' runs-on: ubuntu-latest steps: # Checkout this repo