diff --git a/actions/pull-request/push-branch/action.yml b/actions/pull-request/push-branch/action.yml index 7bb6fd7d..7be44674 100644 --- a/actions/pull-request/push-branch/action.yml +++ b/actions/pull-request/push-branch/action.yml @@ -7,6 +7,10 @@ inputs: branch: description: 'Name of the branch to push' required: true + force: + description: 'Push using --force-with-lease' + required: false + default: "" runs: using: 'docker' @@ -14,3 +18,5 @@ runs: args: - "--branch" - ${{ inputs.branch }} + - "--force" + - ${{ inputs.force }} diff --git a/actions/pull-request/push-branch/entrypoint b/actions/pull-request/push-branch/entrypoint index 4948f9f9..8faf6206 100755 --- a/actions/pull-request/push-branch/entrypoint +++ b/actions/pull-request/push-branch/entrypoint @@ -3,7 +3,7 @@ set -euo pipefail shopt -s inherit_errexit function main() { - local branch + local branch force while [ "${#}" != 0 ]; do case "${1}" in --branch) @@ -11,6 +11,11 @@ function main() { shift 2 ;; + --force) + force="${2}" + shift 2 + ;; + "") shift ;; @@ -22,7 +27,12 @@ function main() { done git config --global --add safe.directory "${GITHUB_WORKSPACE}" - git push origin "${branch}" + + if [[ "${force}" == "true" ]]; then + git push origin "${branch}" --force-with-lease + else + git push origin "${branch}" + fi } main "${@:-}"