Skip to content

Commit

Permalink
feat(rebase): add continue-on-error input
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed May 23, 2023
1 parent 6f7d09d commit 68809e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,14 @@ Rebase two branches and push.

##### Inputs

| Required | Name | Description | Example | Default |
| -------- | -------- | ------------------------------------ | ------------------------------ | -------- |
| Yes | `target` | Target branch you wish to update. | `develop` ||
| Yes | `base` | Base branch to use to rebase target. | `main` ||
| Yes | `token` | GitHub token to use. | `${{ secrets.GH_REPO_TOKEN }}` ||
| No | `force` | Force push. | `true` | `false` |
| No | `remote` | The remote to use | `upstream` | `origin` |
| Required | Name | Description | Example | Default |
| -------- | ------------------- | ------------------------------------ | ------------------------------ | -------- |
| Yes | `target` | Target branch you wish to update. | `develop` ||
| Yes | `base` | Base branch to use to rebase target. | `main` ||
| Yes | `token` | GitHub token to use. | `${{ secrets.GH_REPO_TOKEN }}` ||
| No | `force` | Force push. | `true` | `false` |
| No | `remote` | The remote to use | `upstream` | `origin` |
| No | `continue-on-error` | Continue when rebasing fails | `false` | `true` |

##### Example

Expand All @@ -522,6 +523,7 @@ Rebase two branches and push.
target: develop
force: true
remote: upstream
continue-on-error: false
```

#### update-tags
Expand Down
20 changes: 17 additions & 3 deletions rebase/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ inputs:
required: false
default: 'origin'

continue-on-error:
description: 'Continue when rebasing fails'
required: false
default: 'true' # TODO: change to false in next major version

runs:
using: composite
steps:
Expand All @@ -37,16 +42,25 @@ runs:
id: rebase
shell: bash
run: |
git rebase "${{ inputs.remote }}/${{ inputs.base }}" || (echo "fail=true" >> $GITHUB_OUTPUT && git rebase --abort)
FAILED=false
git rebase "${{ inputs.remote }}/${{ inputs.base }}" || (FAILED=true && git rebase --abort)
if [ "$FAILED" = true ]; then
echo "failed=true" >> $GITHUB_OUTPUT
if [ "${{ inputs.continue-on-error }}" = false ]; then
exit 1
fi
fi
- name: 'Push'
shell: bash
if: inputs.force != 'true' && steps.rebase.outputs.fail != 'true'
if: inputs.force != 'true' && steps.rebase.outputs.failed != 'true'
run: |
git push
- name: 'Force push'
shell: bash
if: inputs.force == 'true' && steps.rebase.outputs.fail != 'true'
if: inputs.force == 'true' && steps.rebase.outputs.failed != 'true'
run: |
git push --force

0 comments on commit 68809e5

Please sign in to comment.