mirror of
https://gitea.com/actions/release-action.git
synced 2024-11-25 15:40:55 -05:00
fix: check response status code before continuing
This commit is contained in:
parent
e5d338f4c5
commit
6f80894884
1 changed files with 4 additions and 1 deletions
5
main.go
5
main.go
|
@ -132,11 +132,14 @@ func getFiles(parentDir, files string) ([]string, error) {
|
||||||
|
|
||||||
func createOrGetRelease(ctx *gha.GitHubContext, c *gitea.Client, owner, repo string, opts gitea.CreateReleaseOption) (*gitea.Release, error) {
|
func createOrGetRelease(ctx *gha.GitHubContext, c *gitea.Client, owner, repo string, opts gitea.CreateReleaseOption) (*gitea.Release, error) {
|
||||||
// Get the release by tag
|
// Get the release by tag
|
||||||
release, _, err := c.GetReleaseByTag(owner, repo, opts.TagName)
|
release, resp, err := c.GetReleaseByTag(owner, repo, opts.TagName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return release, nil
|
return release, nil
|
||||||
}
|
}
|
||||||
errMessage := fmt.Errorf("failed to get release for tag: %s with error: %w", opts.TagName, err)
|
errMessage := fmt.Errorf("failed to get release for tag: %s with error: %w", opts.TagName, err)
|
||||||
|
if resp.StatusCode != 404 {
|
||||||
|
return nil, errMessage
|
||||||
|
}
|
||||||
fmt.Printf("%s trying to create it", errMessage)
|
fmt.Printf("%s trying to create it", errMessage)
|
||||||
// Create the release
|
// Create the release
|
||||||
release, _, err = c.CreateRelease(owner, repo, opts)
|
release, _, err = c.CreateRelease(owner, repo, opts)
|
||||||
|
|
Loading…
Reference in a new issue