diff --git a/README.md b/README.md index 8aad92b..15d27f7 100644 --- a/README.md +++ b/README.md @@ -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. | diff --git a/action.yml b/action.yml index f985c30..3cbfd7b 100644 --- a/action.yml +++ b/action.yml @@ -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.' diff --git a/start.sh b/start.sh index 2cf6345..50a498f 100644 --- a/start.sh +++ b/start.sh @@ -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} @@ -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; \ No newline at end of file