-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from aztfmod/patch.local
Add support for Rover ignite bootstrap from local git clone
- Loading branch information
Showing
2 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,55 @@ | ||
check_github_session() { | ||
debug "github" | ||
set -e | ||
information "@call check_github_session" | ||
url=$(git config --get remote.origin.url) | ||
export git_org_project=$(echo "$url" | sed -e 's#^https://github.com/##; s#^[email protected]:##; s#.git$##') | ||
export git_project=$(basename -s .git $(git config --get remote.origin.url)) | ||
success "Connected to GiHub: repos/${git_org_project}" | ||
project=$(/usr/bin/gh api "repos/${git_org_project}" 2>/dev/null | jq -r .id) | ||
export GITOPS_SERVER_URL=$(/usr/bin/gh api "repos/${git_org_project}" 2>/dev/null | jq -r .svn_url) | ||
debug "${project}" | ||
|
||
verify_github_secret "actions" "BOOTSTRAP_TOKEN" | ||
|
||
if [ ! -v ${CODESPACES} ]; then | ||
verify_github_secret "codespaces" "GH_TOKEN" | ||
fi | ||
|
||
verify_git_settings "git config --global user.name" | ||
verify_git_settings "git config --global user.email" | ||
|
||
/usr/bin/gh auth status | ||
} | ||
|
||
verify_git_settings(){ | ||
information "@call verify_git_settings for ${1}" | ||
|
||
command=${1} | ||
eval ${command} | ||
|
||
RETURN_CODE=$? | ||
if [ $RETURN_CODE != 0 ]; then | ||
error ${LINENO} "You need to set a value for ${command} before running the rover bootstrap." $RETURN_CODE | ||
fi | ||
} | ||
|
||
verify_github_secret() { | ||
information "@call verify_github_secret for ${1}/${2}" | ||
|
||
application=${1} | ||
secret_name=${2} | ||
|
||
/usr/bin/gh secret list -a ${application} | grep "${secret_name}" | ||
|
||
RETURN_CODE=$? | ||
|
||
echo "return code ${RETURN_CODE}" | ||
|
||
set -e | ||
if [ $RETURN_CODE != 0 ]; then | ||
error ${LINENO} "You need to set the ${application}/${secret_name} in your project as per instructions in the documentation." $RETURN_CODE | ||
fi | ||
} | ||
|
||
register_github_secret() { | ||
debug "@call register_github_secret for ${1}" | ||
|
||
|