Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
fix: remote URL querying of repos cloned using an SSH key (#122)
Browse files Browse the repository at this point in the history
* fix: remote URL querying of repos cloned using an SSH key

Fixes #120.

* perf: improve `sed` scripts and minimize usage of conditionals

* perf: remove unnecessary conditionals
  • Loading branch information
m4heshd authored Jan 19, 2023
1 parent 094e8d4 commit 5723317
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,7 @@ echo_info "DESTINATION_BRANCH=$DESTINATION_BRANCH"
# Determine repository url
if [[ -z "$INPUT_DESTINATION_REPOSITORY" ]]; then
# Try to query local repository's remote url if INPUT_DESTINATION_REPOSITORY is null
local_origin=$(git remote get-url origin)

if [[ "$local_origin" == *.git ]]; then
origin_no_suffix="${local_origin%.*}"
else
origin_no_suffix="$local_origin"
fi

repo="$(basename "${origin_no_suffix}")"
owner="$(basename "${origin_no_suffix%/${repo}}")"

if [[ ! -z "$repo" ]]; then
CHECKOUT_REPOSITORY="$owner/$repo"
fi
CHECKOUT_REPOSITORY=$(git remote get-url origin | sed -r -e 's:https\://([^/]+)/([^/]+)/([^.]+)(.*):\2\/\3:g' -e 's:git@([^/]+)\:([^/]+)/([^.]+)(.*):\2\/\3:g')
fi

# Fallback to GITHUB_REPOSITORY if both INPUT_DESTINATION_REPOSITORY and CHECKOUT_REPOSITORY are unavailable
Expand Down

0 comments on commit 5723317

Please sign in to comment.