Skip to content

Commit

Permalink
Add ability to pull before push (#23)
Browse files Browse the repository at this point in the history
* Add ability to pull before push

* make rebase explicit

* revert change

---------

Co-authored-by: flxdot <[email protected]>
  • Loading branch information
flxdot and flxdot authored Apr 17, 2024
1 parent 156f2b1 commit 2ee7360
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
| amend | boolean | false | Determines if the commit should be amended. Needs to be used with `force` input to force push the amended commit. |
| force | boolean | false | Determines if force push is used. |
| tags | boolean | false | Determines if `--tags` is used. |
| rebase | boolean | false | Determines if `git pull --rebase` is used before the push. This is useful if multiple actions try to push at the same time. |
| directory | string | '.' | Directory to change to before pushing. |
| repository | string | '' | Repository name. Default or empty repository name represents current github repository. If you want to push to other repository, you should make a [personal access token](https://github.com/settings/tokens) and use it as the `github_token` input. |

Expand Down
15 changes: 9 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,28 @@ inputs:
description: 'Commit message.'
required: false
repository:
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY}).'
default: ''
required: false
branch:
description: 'Destination branch to push changes'
description: 'Destination branch to push changes.'
required: false
default: 'main'
empty:
description: 'Allow empty commit'
description: 'Allow empty commit.'
required: false
amend:
description: 'Determines if the commit should be amended'
description: 'Determines if the commit should be amended.'
required: false
default: 'false'
force:
description: 'Determines if force push is used'
description: 'Determines if force push is used.'
required: false
tags:
description: 'Determines if --tags is used'
description: 'Determines if --tags is used.'
required: false
rebase:
description: 'Determines if `git pull --rebase` is used before the push. This is useful if multiple actions try to push at the same time.'
required: false
directory:
description: 'Directory to change to before pushing.'
Expand Down
5 changes: 5 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ INPUT_BRANCH=${INPUT_BRANCH:-master}
INPUT_AMEND=${INPUT_AMEND:-false}
INPUT_FORCE=${INPUT_FORCE:-false}
INPUT_TAGS=${INPUT_TAGS:-false}
INPUT_REBASE=${INPUT_REBASE:-false}
INPUT_EMPTY=${INPUT_EMPTY:-false}
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
Expand Down Expand Up @@ -66,4 +67,8 @@ else
git commit -m "${INPUT_MESSAGE}" $_EMPTY || exit 0
fi

if ${INPUT_REBASE}; then
git pull --rebase
fi

git push "${remote_repo}" HEAD:"${INPUT_BRANCH}" --follow-tags $_FORCE_OPTION $_TAGS;

0 comments on commit 2ee7360

Please sign in to comment.