From 335ab335ee8f152623d5ce638127c6b642f4a5ca Mon Sep 17 00:00:00 2001 From: na-ga <537006+na-ga@users.noreply.github.com> Date: Mon, 25 Oct 2021 13:53:56 +0900 Subject: [PATCH] Fix exist release tag --- github.go | 8 ++++---- main.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/github.go b/github.go index efb234a..3620790 100644 --- a/github.go +++ b/github.go @@ -140,10 +140,10 @@ func createRelease(ctx context.Context, client *github.Client, owner, repo strin func existRelease(ctx context.Context, client *github.Client, owner, repo, tag string) (bool, error) { _, resp, err := client.Repositories.GetReleaseByTag(ctx, owner, repo, tag) if err != nil { + if resp != nil && resp.StatusCode == http.StatusNotFound { + return false, nil + } return false, err } - if resp.StatusCode == http.StatusNotFound { - return false, nil - } - return true, nil + return resp.StatusCode == http.StatusOK, nil } diff --git a/main.go b/main.go index 68aa6e5..1d804d0 100644 --- a/main.go +++ b/main.go @@ -108,10 +108,10 @@ func main() { existingProposals = make([]ReleaseProposal, 0) ) for _, p := range proposals { - if p.PreTag != "" { - exist, err := existRelease(ctx, ghClient, event.Owner, event.Repo, p.PreTag) + if p.Tag != "" { + exist, err := existRelease(ctx, ghClient, event.Owner, event.Repo, p.Tag) if err != nil { - log.Fatalf("Failed to check the existence of release for %s: %v\n", p.PreTag, err) + log.Fatalf("Failed to check the existence of release for %s: %v\n", p.Tag, err) } if exist { existingProposals = append(existingProposals, p)