Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Add autosquash #83

Merged
merged 3 commits into from May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Expand Up @@ -18,8 +18,12 @@ on:
jobs:
rebase:
name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
if: >-
github.event.issue.pull_request != '' &&
(
contains(github.event.comment.body, '/rebase') ||
contains(github.event.comment.body, '/autosquash')
) runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
Expand All @@ -28,6 +32,8 @@ jobs:
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.5
with:
autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down
14 changes: 14 additions & 0 deletions action.yml
@@ -0,0 +1,14 @@
name: Automatic Rebase
description: Automatically rebases PR on '/rebase' comment
maintainer: Cirrus Labs
runs:
using: 'docker'
image: 'Dockerfile'
inputs:
autosquash:
description: Should the rebase autosquash fixup and squash commits
required: false
default: false
branding:
icon: git-pull-request
color: purple
6 changes: 5 additions & 1 deletion entrypoint.sh
Expand Up @@ -100,7 +100,11 @@ git fetch fork $HEAD_BRANCH

# do the rebase
git checkout -b fork/$HEAD_BRANCH fork/$HEAD_BRANCH
git rebase origin/$BASE_BRANCH
if [[ $INPUT_AUTOSQUASH -eq 'true' ]]; then
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash origin/$BASE_BRANCH
else
git rebase origin/$BASE_BRANCH
fi

# push back
git push --force-with-lease fork fork/$HEAD_BRANCH:$HEAD_BRANCH