Skip to content

Commit

Permalink
try to preserve merges
Browse files Browse the repository at this point in the history
  • Loading branch information
k8adev committed Jan 13, 2024
1 parent 1562968 commit 37695c8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ jobs:
fetch-depth: 0
ref: ${{ env.GH_BRANCH }}

- name: Configure git
run: |
# Use the author of the last commit as the committer
git config user.name $(git log -1 --pretty=format:'%an')
git config user.email $(git log -1 --pretty=format:'%ae')
# Keep the original author date
git config rebase.instructionFormat '%s%nexec GIT_COMMITTER_DATE="%cD" git commit --amend --no-edit --reset-author --date="%cD"'
shell: bash

- id: branch_status
name: Check if branch is up-to-date
run: |
Expand All @@ -52,15 +62,8 @@ jobs:
- name: Try to rebase
if: ${{ steps.branch_status.outputs.up_to_date == 'false' }}
run: |
# Use the author of the last commit as the committer
git config user.name $(git log -1 --pretty=format:'%an')
git config user.email $(git log -1 --pretty=format:'%ae')
# Keep the original author date
git config rebase.instructionFormat '%s%nexec GIT_COMMITTER_DATE="%cD" git commit --amend --no-edit --reset-author --date="%cD"'
git fetch origin ${{ env.GH_BRANCH_BASE }}
git pull --rebase origin ${{ env.GH_BRANCH_BASE }}
git rebase --rebase-merges origin ${{ env.GH_BRANCH_BASE }}
# Edit last commit message to include [skip ci] and avoid triggering subsequent workflows
git commit --amend -m "$(git log -1 --pretty=%B) [skip ci]"
Expand Down

0 comments on commit 37695c8

Please sign in to comment.