Skip to content

Commit

Permalink
fix: log request-id on upload error and release create/update (#3608)
Browse files Browse the repository at this point in the history
this should help when reporting issues to github, especially the magical
"failed successfully" error

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Nov 30, 2022
1 parent 24d8647 commit 50bd784
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions internal/client/github.go
Expand Up @@ -252,12 +252,19 @@ func (c *githubClient) createOrUpdateRelease(ctx *context.Context, data *github.
data.GetTagName(),
)
if err != nil {
release, _, err = c.client.Repositories.CreateRelease(
release, resp, err := c.client.Repositories.CreateRelease(
ctx,
ctx.Config.Release.GitHub.Owner,
ctx.Config.Release.GitHub.Name,
data,
)
if err == nil {
log.WithFields(log.Fields{
"name": data.GetName(),
"release-id": release.GetID(),
"request-id": resp.Header.Get("X-GitHub-Request-Id"),
}).Info("release created")
}
return release, err
}

Expand All @@ -266,14 +273,21 @@ func (c *githubClient) createOrUpdateRelease(ctx *context.Context, data *github.
}

func (c *githubClient) updateRelease(ctx *context.Context, id int64, data *github.RepositoryRelease) (*github.RepositoryRelease, error) {
repo, _, err := c.client.Repositories.EditRelease(
release, resp, err := c.client.Repositories.EditRelease(
ctx,
ctx.Config.Release.GitHub.Owner,
ctx.Config.Release.GitHub.Name,
id,
data,
)
return repo, err
if err == nil {
log.WithFields(log.Fields{
"name": data.GetName(),
"release-id": release.GetID(),
"request-id": resp.Header.Get("X-GitHub-Request-Id"),
}).Info("release updated")
}
return release, err
}

func (c *githubClient) ReleaseURLTemplate(ctx *context.Context) (string, error) {
Expand Down Expand Up @@ -310,6 +324,13 @@ func (c *githubClient) Upload(
},
file,
)
if err != nil {
log.WithFields(log.Fields{
"name": artifact.Name,
"release-id": releaseID,
"request-id": resp.Header.Get("X-GitHub-Request-Id"),
}).Warn("upload failed")
}
if err == nil {
return nil
}
Expand Down

0 comments on commit 50bd784

Please sign in to comment.