Skip to content
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

Use new Code Connections process #82

Open
ipmb opened this issue Oct 28, 2024 · 0 comments
Open

Use new Code Connections process #82

ipmb opened this issue Oct 28, 2024 · 0 comments

Comments

@ipmb
Copy link
Member

ipmb commented Oct 28, 2024

The old process was cumbersome and error-prone. The new process looks better. We should be able to create the connection via the CLI and then open a browser for the user to install the app at GitHub.

https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-github.html#connections-create-github-cli

Relevant code:

  • func verifySourceCredentials(sess *session.Session, repositoryType string) error {
    codebuildSvc := codebuild.New(sess)
    sourceCredentialsOutput, err := codebuildSvc.ListSourceCredentials(&codebuild.ListSourceCredentialsInput{})
    if err != nil {
    return err
    }
    hasCredentials := false
    for _, cred := range sourceCredentialsOutput.SourceCredentialsInfos {
    if *cred.ServerType == repositoryType {
    hasCredentials = true
    }
    }
    if !hasCredentials {
    var friendlySourceName string
    if repositoryType == "BITBUCKET" {
    friendlySourceName = "Bitbucket"
    } else if repositoryType == "GITHUB" {
    friendlySourceName = "GitHub"
    } else {
    return fmt.Errorf("unsupported repository type: %s", repositoryType)
    }
    ui.Spinner.Stop()
    ui.PrintWarning(fmt.Sprintf("CodeBuild needs to be authenticated to access your repository at %s", friendlySourceName))
    fmt.Println("On the CodeBuild new project page:")
    fmt.Printf(" 1. Scroll to the %s section\n", aurora.Bold("Source"))
    fmt.Printf(" 2. Select %s for the %s\n", aurora.Bold(friendlySourceName), aurora.Bold("Source provider"))
    fmt.Printf(" 3. Keep the default %s\n", aurora.Bold("Connect using OAuth"))
    fmt.Printf(" 4. Click %s\n", aurora.Bold(fmt.Sprintf("Connect to %s", friendlySourceName)))
    fmt.Printf(" 5. Click %s in the popup window\n", aurora.Bold("Confirm"))
    fmt.Printf(" 6. %s You can close the browser window and continue with app setup here.\n\n", aurora.Bold("That's it!"))
    newProjectURL := fmt.Sprintf("https://%s.console.aws.amazon.com/codesuite/codebuild/project/new", *sess.Config.Region)
    url, err := auth.GetConsoleURL(sess, newProjectURL)
    if err == nil && isatty.IsTerminal(os.Stdin.Fd()) {
    fmt.Println("Opening the CodeBuild new project page now...")
    err = browser.OpenURL(*url)
    if err != nil {
    fmt.Println("Open this URL in your browser to view logs:")
    fmt.Println(*url)
    }
    } else {
    fmt.Printf("Visit the following URL to authenticate: %s", newProjectURL)
    }
    ui.PauseUntilEnter("Finish authentication in your web browser then press ENTER to continue.")
    return verifySourceCredentials(sess, repositoryType)
    }
    return nil
    }
  • https://github.com/apppackio/apppack-docs/blob/61a96fdf4424663f235f03a3d52c593e8b90a6b2/src/tutorials/deploy-first-app.md#L50-L60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant