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

Add support for a new /build API #324

Closed
Tracked by #328
calebhailey opened this issue Sep 27, 2021 · 3 comments
Closed
Tracked by #328

Add support for a new /build API #324

calebhailey opened this issue Sep 27, 2021 · 3 comments
Assignees
Milestone

Comments

@calebhailey
Copy link

calebhailey commented Sep 27, 2021

Add support for a new /build API which can be called from CI after successful builds, thereby eliminating the various race conditions resulting from our current dependency on GitHub Webhooks.

Requires should require a GitHub token be provided as a HTTP Header w/ requests to the /build API, then use this token to verify that the requester is authorized to request an asset build (see "List repositories for the authorized user").

Notes:

@calebhailey calebhailey added this to the 6.6.0 milestone Sep 27, 2021
This was referenced Sep 27, 2021
@calebhailey
Copy link
Author

Related (but out of scope for this issue): #336

@jspaleta
Copy link

Straw implementation

  1. User sends github personal access token to bonsai build

  2. Bonsai finds user login name for access token using github api endput /user
    Ex:

curl   -H "Accept: application/vnd.github.v3+json"   -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/user
{
  "login": "jspaleta",
  ...
}

  1. Bonsai determines if user connected with access token is a collaborator on a repo /repos/{owner}/{repo}/collaborators/{username}
    return status 204 indicates user is a collaborator
curl   -H "Accept: application/vnd.github.v3+json"   -H "Authorization: token ${GITHUB_TOKEN}"  -s -o /dev/null -w "%{http_code}"  https://api.github.com/repos/sensu/sensu-go-workshop/collaborators/jspaleta
204
  1. Use personal access token with github api releases endpoint to pull github release assets as needed.

Note: this should work with both public and private repositories if personal access token is given repo scope.

@calebhailey
Copy link
Author

Closed via #337

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

3 participants