From 80d5d3f9284b0ef89e5fc3f682a7a602cdb80332 Mon Sep 17 00:00:00 2001 From: jojomatik Date: Thu, 10 Mar 2022 19:29:45 +0100 Subject: [PATCH] feat: add strategy `rebase` Add strategy `rebase` that rebases the commits in the target branch onto the source branch. Closes #1 --- README.md | 3 ++- action.yml | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f87505a..e33ea48 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,12 @@ jobs: # Optional # Default: `beta` target: "v1" - # The strategy to use, if fast-forward is not possible (merge, force, fail). + # The strategy to use, if fast-forward is not possible (merge, rebase, force, fail). # Optional # Default: `merge` # Possible values: # - `merge`: merge the source branch into the target branch + # - `rebase`: rebase the target branch onto the source branch # - `force`: force push the source branch to the target branch (overrides any changes on the target # branch) # - `fail`: pushes the source branch to the target branch, fails if the target branch contains changes diff --git a/action.yml b/action.yml index b1186d8..d5bd59a 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,14 @@ runs: if: inputs.strategy == 'merge' run: git push shell: bash + - name: Rebase ${{ inputs.target }} onto ${{ inputs.source }} + if: inputs.strategy == 'rebase' + run: git rebase ${{ inputs.source }} ${{ inputs.target }} + shell: bash + - name: Force push ${{ inputs.target }} + if: inputs.strategy == 'rebase' + run: git push --force origin ${{ inputs.target }} + shell: bash - name: Force push ${{ inputs.source }} to ${{ inputs.target }} if: inputs.strategy == 'force' run: git push --force origin ${{ inputs.source }}:${{ inputs.target }}