Update origin url to include token for pushing
This commit is contained in:
@@ -11,6 +11,10 @@ inputs:
|
||||
description: 'Branch receiving updates from the upstream repo, e.g. => main, master, prod'
|
||||
required: true
|
||||
|
||||
source_repo_token:
|
||||
description: 'Input for passing secrets.GITHUB_TOKEN when disabling persistent auth in the checkout step'
|
||||
required: false
|
||||
|
||||
upstream_repo_access_token:
|
||||
description: 'Token for accessing the remote repo through HTTPS authentication'
|
||||
required: false
|
||||
|
||||
@@ -16,6 +16,12 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "${GITHUB_ACTIONS}" = false ]; then
|
||||
# region vars
|
||||
# Github login of the user initiating the workflow run
|
||||
GITHUB_ACTOR="aormsby"
|
||||
|
||||
# TODO: figure out local mode defaults and use
|
||||
# shellcheck disable=SC2034
|
||||
INPUT_SOURCE_REPO_TOKEN=""
|
||||
# shellcheck disable=SC2034
|
||||
GITHUB_REPOSITORY=""
|
||||
|
||||
# required vars (except token)
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
push_new_commits() {
|
||||
write_out -1 'Pushing synced data to source branch.'
|
||||
|
||||
# TODO: figure out hwo this would work in local mode...
|
||||
# update origin url with token since it is not persisted during checkout step when syncing from a private repo
|
||||
if [ -n "${INPUT_UPSTREAM_REPO_ACCESS_TOKEN}" ]; then
|
||||
echo "github token - ${INPUT_SOURCE_REPO_TOKEN}"
|
||||
git remote set-url origin "https://${GITHUB_ACTOR}:${INPUT_SOURCE_REPO_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
git push ${INPUT_SOURCE_PUSH_ARGS} origin "${INPUT_SOURCE_SYNC_BRANCH}"
|
||||
COMMAND_STATUS=$?
|
||||
|
||||
Reference in New Issue
Block a user