Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion merge/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,24 @@ git remote prune origin
failures=()

function open_and_merge_pull_request() {
local source_branch="${GITHUB_REF#refs/heads/}"

echo "DEBUG: making pull request from ${GITHUB_REF} to $1"

# if $1 branch does not exist origin
# if destination branch does not exist on origin
if [[ -z "$(git ls-remote origin "$1")" ]]; then
echo "Could not find expected branch '$1' on remote 'origin'"
Comment thread
abbiejones marked this conversation as resolved.
return 1
fi

# Skip no-op merges so identical branches do not fail PR creation with
# "No commits between ..." validation errors.
local ahead_commit
ahead_commit="$(git rev-list --max-count=1 "origin/$1..origin/${source_branch}")"

Comment thread
abbiejones marked this conversation as resolved.
if [[ -z "${ahead_commit}" ]]; then
echo "DEBUG: skipping merge of ${GITHUB_REF} into $1; ${source_branch} has no commits ahead of $1"
return 0
fi

# subshell with +e so we continue on errors
Expand Down
Loading