8000 Add support for Rover ignite bootstrap from local git clone by LaurentLesle · Pull Request #279 · aztfmod/rover · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for Rover ignite bootstrap from local git clone #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions scripts/lib/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ assert_gitops_session() {

case "${1}" in
"github")
GITOPS_SERVER_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
AGENT_TOKEN=$(gh api --method POST -H "Accept: application/vnd.github.v3+json" /repos/${GITHUB_REPOSITORY}/actions/runners/registration-token | jq -r .token)
check_github_session
AGENT_TOKEN=$(gh api --method POST -H "Accept: application/vnd.github.v3+json" /repos/${git_org_project}/actions/runners/registration-token | jq -r .token)
;;
"tfcloud")
GITOPS_SERVER_URL="https://${TF_VAR_tf_cloud_hostname}"
Expand Down
44 changes: 42 additions & 2 deletions scripts/lib/github.com.sh
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#^git@github.com:##; 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}"

Expand Down
0