From 89d04c2fd0e1f3f3188a4c26be2a69f2b17dc581 Mon Sep 17 00:00:00 2001 From: Rob Dimsdale-Zucker Date: Tue, 4 Jun 2024 14:37:41 -0700 Subject: [PATCH] Add optional --force-with-lease to pr push action. --- actions/pull-request/push-branch/action.yml | 6 ++++++ actions/pull-request/push-branch/entrypoint | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) 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 "${@:-}"