Skip to content

Commit 5485eef

Browse files
committed
ci: add/update workflow for autosquash on PRs
1 parent 15dc92a commit 5485eef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/tf-autosquash.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ jobs:
7676
git config --global user.name "github-actions[bot]"
7777
git config --global user.email "github-actions[bot]@users.noreply.github.com"
7878
79+
- name: Remember author and email of last commit
80+
run: |
81+
LAST_COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
82+
LAST_COMMIT_EMAIL=$(git log -1 --pretty=format:"%ae")
83+
echo "LAST_COMMIT_AUTHOR=$LAST_COMMIT_AUTHOR" >> $GITHUB_ENV
84+
echo "LAST_COMMIT_EMAIL=$LAST_COMMIT_EMAIL" >> $GITHUB_ENV
85+
7986
- name: Perform interactive rebase with autosquash
8087
env:
8188
EDITOR: 'true' # to automatically complete the interactive rebase
@@ -84,6 +91,15 @@ jobs:
8491
git fetch origin
8592
git rebase -i --autosquash origin/$BASE_REF
8693
94+
- name: Replace renovate author to prevent renovate overriding changes
95+
env:
96+
EDITOR: 'true' # to automatically complete the amend
97+
run: |
98+
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
99+
if [ "$COMMIT_AUTHOR" = "renovate[bot]" ] || [ "$COMMIT_AUTHOR" = "we-renovate[bot]" ]; then
100+
git commit --amend --author="$LAST_COMMIT_AUTHOR <$LAST_COMMIT_EMAIL>"
101+
fi
102+
87103
- name: Push changes
88104
run: |
89105
git push --force-with-lease

0 commit comments

Comments
 (0)