diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e21cef..d6ad308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.0.7](https://github.com/kudoas/sync-issue-field/compare/v0.0.6...v0.0.7) (2024-04-21) + + +### Bug Fixes + +* use return early ([#19](https://github.com/kudoas/sync-issue-field/issues/19)) ([282d275](https://github.com/kudoas/sync-issue-field/commit/282d275d997b06fe4a0b2e944e27e9cf6f5f2b5b)) + ## [0.0.6](https://github.com/kudoas/sync-issue-field/compare/v0.0.5...v0.0.6) (2024-04-21) diff --git a/action.yml b/action.yml index 9d95836..c4744be 100644 --- a/action.yml +++ b/action.yml @@ -1,12 +1,12 @@ -name: "Sync GitHub Issue" -description: "Sync GitHub Parent Issue to Child Issue" +name: "Sync Issue Field" +description: "Sync GitHub parent issue's fields to child issue's fields." author: "kudoas" inputs: repository: - description: "Repository name with owner. For example, kudoas/gis'" + description: "Repository name with owner. For example, kudoas/sync-issue-field. Default is the current repository." default: ${{ github.repository }} issue: - description: "The number that identifies the issue. Specify the child issue you wish to synchronize with the parent issue" + description: "The number that identifies the issue. Specify the child issue you wish to synchronize with the parent issue. Default is the current issue." default: ${{ github.event.issue.number }} token: description: "GitHub Token" diff --git a/main.go b/main.go index 4361eb3..31e841b 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,7 @@ func main() { }); err != nil { log.Fatalf("failed to get parent issue: %v", err) } + mi := mutate.NewMutationIssue() input := githubv4.UpdateIssueInput{ ID: i.GetIssueID(), @@ -53,7 +54,12 @@ func main() { if err := mi.Mutate(client, context.Background(), input); err != nil { log.Fatalf("failed to update issue: %v", err) } + mp := mutate.NewMutationProject() + projectID := p.GetProjectID() + if projectID == nil { + return + } if err := mp.Mutate(client, githubv4.AddProjectV2ItemByIdInput{ ProjectID: p.GetProjectID(), ContentID: i.GetIssueID(), diff --git a/query/issue.go b/query/issue.go index 13ae0e3..e6dc654 100644 --- a/query/issue.go +++ b/query/issue.go @@ -2,7 +2,7 @@ package query import ( "context" - "fmt" + "log" "os" "github.com/shurcooL/githubv4" @@ -35,6 +35,7 @@ func (i *IssueID) GetIssueID() githubv4.ID { func (i *IssueID) GetParentIssueID() githubv4.ID { if len(i.Repository.Issue.TrackedInIssues.Nodes) == 0 { + log.Println("not found parent issue") os.Exit(0) } return i.Repository.Issue.TrackedInIssues.Nodes[0].ID @@ -100,9 +101,8 @@ func (p *ParentIssue) GetMilestoneID() *githubv4.ID { } func (p *ParentIssue) GetProjectID() githubv4.ID { - println(fmt.Sprintf("%+v", p.Node.Issue.ProjectItems.Nodes)) if len(p.Node.Issue.ProjectItems.Nodes) == 0 { - os.Exit(0) + return nil } return p.Node.Issue.ProjectItems.Nodes[0].Project.ID }