Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Augustin <[email protected]>
  • Loading branch information
AndreasAugustin committed Jan 27, 2025
1 parent f3feb97 commit 7e32cd6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
18 changes: 13 additions & 5 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ if [[ -z "${HOME}" ]]; then
exit 1
fi

if [[ -z "${GITHUB_SERVER_URL}" ]]; then
err "Missing env variable 'GITHUB_SERVER_URL' of the target github server. E.g. https://github.com"
fi

if ! [ -x "$(command -v gh)" ]; then
err "github-cli gh is not installed. 'https://github.com/cli/cli'";
exit 1;
Expand Down Expand Up @@ -177,15 +181,19 @@ function git_init() {
fi
###############################
if [[ -z "${SOURCE_GH_TOKEN}" ]]; then
err "Missing input 'source_github_token: \${{ secrets.GITHUB_TOKEN }}'.";
err "Missing input 'source_gh_token: \${{ secrets.GITHUB_TOKEN }}'.";
exit 1;
fi
info "login to the source git repository"
gh auth login --git-protocol "https" --hostname "${SOURCE_REPO_HOSTNAME}" --with-token <<< "${SOURCE_GH_TOKEN}"
gh auth status
# if [[ -n "${TARGET_GH_TOKEN}" ]]; then
# gh auth login --git-protocol "https" --hostname "${SOURCE_REPO_HOSTNAME}" --with-token <<< "${TARGET_GH_TOKEN}"
# fi
# gh auth switch
if [[ -n "${TARGET_GH_TOKEN}" ]]; then
info "login to the target git repository"
gh auth login --git-protocol "https" --hostname "${GITHUB_SERVER_URL}" --with-token <<< "${TARGET_GH_TOKEN}"
gh auth status
fi
gh auth switch
gh auth status
gh auth setup-git --hostname "${source_repo_hostname}"
info "done set git global configuration"
else
Expand Down
8 changes: 2 additions & 6 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ if [[ -z "${SOURCE_REPO}" ]]; then
exit 1;
fi

if [[ -z "${GITHUB_SERVER_URL}" ]]; then
err "Missing env variable 'GITHUB_SERVER_URL' of the target github server. E.g. https://github.com"
fi

if ! [ -x "$(command -v gh)" ]; then
err "github-cli gh is not installed. 'https://github.com/cli/cli'";
exit 1;
Expand Down Expand Up @@ -255,8 +251,8 @@ function pull_source_changes() {

if [[ -n "${SRC_SSH_PRIVATEKEY_ABS_PATH}" ]] &>/dev/null; then
info "we are using ssh for the source repo. No need to logout."
elif [[ -n "${SOURCE_GH_TOKEN}" ]] &>/dev/null; then
gh auth switch
elif [[ -n "${SOURCE_GH_TOKEN}" ]] &>/dev/null; then
gh auth switch
fi

if [ "$pull_has_issues" == true ] ; then
Expand Down

0 comments on commit 7e32cd6

Please sign in to comment.