-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathstatuses.go
More file actions
28 lines (25 loc) · 807 Bytes
/
statuses.go
File metadata and controls
28 lines (25 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package github
import (
"context"
"fmt"
hc "github.com/CircleCI-Public/chunk-cli/internal/httpcl"
)
// CreateCommitStatus posts a commit status for the given SHA.
// state must be one of: "pending", "success", "failure", "error".
// statusContext is the check name shown in GitHub (e.g. "chunk/test").
func (c *Client) CreateCommitStatus(ctx context.Context, owner, repo, sha, state, statusContext, description string) error {
body := map[string]string{
"state": state,
"context": statusContext,
"description": description,
}
req := hc.NewRequest("POST", "/repos/%s/%s/statuses/%s",
hc.RouteParams(owner, repo, sha),
hc.Body(body),
)
_, err := c.http.Call(ctx, req)
if err == nil {
return nil
}
return mapErr(fmt.Sprintf("create commit status %s", statusContext), err)
}