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

Commit

Permalink
Add and use autosquash action input
Browse files Browse the repository at this point in the history
By using an input to trigger whether to rebase with autosquash, we can
enable other kinds of workflow configurations (e.g. other events and
criteria).
  • Loading branch information
samholmes committed Jul 1, 2021
1 parent d12f489 commit 06c023c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -28,6 +28,8 @@ jobs:
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.4
with:
autosquash: ${{ contains(github.event.comment.body, '/rebase-autosquash') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Expand Up @@ -4,6 +4,11 @@ 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 @@ -97,7 +97,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

0 comments on commit 06c023c

Please sign in to comment.