Skip to content

Commit

Permalink
Add optional --force-with-lease to pr push action.
Browse files Browse the repository at this point in the history
  • Loading branch information
robdimsdale committed Jun 5, 2024
1 parent b929f04 commit 89d04c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions actions/pull-request/push-branch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ inputs:
branch:
description: 'Name of the branch to push'
required: true
force:
description: 'Push using --force-with-lease'
required: false
default: ""

runs:
using: 'docker'
image: 'Dockerfile'
args:
- "--branch"
- ${{ inputs.branch }}
- "--force"
- ${{ inputs.force }}
14 changes: 12 additions & 2 deletions actions/pull-request/push-branch/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ set -euo pipefail
shopt -s inherit_errexit

function main() {
local branch
local branch force
while [ "${#}" != 0 ]; do
case "${1}" in
--branch)
branch="${2}"
shift 2
;;

--force)
force="${2}"
shift 2
;;

"")
shift
;;
Expand All @@ -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 "${@:-}"

0 comments on commit 89d04c2

Please sign in to comment.