Skip to content

Commit

Permalink
ci: Don't push commits merged in the upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
akirak committed Nov 4, 2023
1 parent 3c65d0b commit 0bdad0b
Showing 1 changed file with 8 additions and 42 deletions.
50 changes: 8 additions & 42 deletions .github/workflows/merge-upstream.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Merge upstream recipes
name: Update the recipes

on:
workflow_dispatch:
Expand Down Expand Up @@ -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

0 comments on commit 0bdad0b

Please sign in to comment.