From 0bdad0b85a417b67b3516c0b9566ca2a832bb73b Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Sun, 5 Nov 2023 03:28:49 +0900 Subject: [PATCH] ci: Don't push commits merged in the upstream --- .github/workflows/merge-upstream.yml | 50 +++++----------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/.github/workflows/merge-upstream.yml b/.github/workflows/merge-upstream.yml index a4dc56ff759..03a9c7acfc4 100644 --- a/.github/workflows/merge-upstream.yml +++ b/.github/workflows/merge-upstream.yml @@ -1,4 +1,4 @@ -name: Merge upstream recipes +name: Update the recipes on: workflow_dispatch: @@ -26,57 +26,23 @@ jobs: sparse-checkout: '.' ref: ${{ matrix.base_ref }} - - name: Switch to a work branch - id: start - run: | - echo "rev=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - - - name: Install git-filter-repo - run: | - sudo apt-get update && sudo apt-get install git-filter-repo --yes - - name: Fetch the upstream run: | git remote add upstream ${{ matrix.upstream }} git fetch upstream ${{ matrix.upstream_branch }} - - name: Configure the Git identity - run: | - # Set some identity. Actually it will be overridden later by git-filter-repo, - # so it can be anything - git config --add user.name 'github-actions[bot]' - git config --add user.email '6270544+github-actions[bot]@users.noreply.github.com' - - - name: Retrieve the merge base - id: merge-base - run: | - rev=$(git merge-base upstream/${{ matrix.upstream_branch }} ${{ matrix.base_ref }}) - echo "rev=$rev" > "$GITHUB_OUTPUT" - - - name: Filter commits - run: | - git switch -C upstream-recipes upstream/${{ matrix.upstream_branch }} - git-filter-repo \ - --path recipes/ --refs "${{ steps.merge-base.outputs.rev }}..HEAD" \ - --commit-callback ' - commit.committer_name = commit.author_name - commit.committer_email = commit.author_email - commit.committer_date = commit.author_date - ' --force - - - name: Rebase + - name: Make a temporary branch run: | - git rebase -s ort -X ours ${{ steps.start.outputs.rev }} + git switch -C tmp upstream/${{ matrix.upstream_branch }} + git push --force origin HEAD - - name: Merge into the original branch + - name: Cherry pick commits run: | - git switch ${{ matrix.base_ref }} - git merge --ff upstream-recipes + git cherry-pick --strategy ort -X theirs ..${{ matrix.base_ref }} - name: Create a pull request uses: peter-evans/create-pull-request@v5 with: - branch: create-pull-request/recipes - token: ${{ secrets.PAT_FOR_PR }} - title: 'Merge upstream recipe commits' + branch: My recipes + title: 'Rebase my branch onto the latest upstream' labels: automation