Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/integrations/github/create_issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"

"github.com/google/go-github/v74/github"
"github.com/google/uuid"
Expand Down Expand Up @@ -120,6 +121,12 @@ func (c *CreateIssueComment) Setup(ctx core.SetupContext) error {
return errors.New("body is required")
}

// Repository can be expression-based (resolved at runtime), so skip
// setup-time installation validation for templated values.
if strings.Contains(config.Repository, "{{") {
return nil
}

return ensureRepoInMetadata(
ctx.Metadata,
ctx.Integration,
Expand Down
19 changes: 19 additions & 0 deletions pkg/integrations/github/create_issue_comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ func Test__CreateIssueComment__Setup(t *testing.T) {
require.ErrorContains(t, err, "repository world is not accessible to app installation")
})

t.Run("repository expression skips setup validation", func(t *testing.T) {
integrationCtx := &contexts.IntegrationContext{
Metadata: Metadata{
Repositories: []Repository{helloRepo},
},
}
nodeMetadataCtx := contexts.MetadataContext{}
require.NoError(t, component.Setup(core.SetupContext{
Integration: integrationCtx,
Metadata: &nodeMetadataCtx,
Configuration: map[string]any{
"issueNumber": "42",
"body": "test",
"repository": `{{$["github.onWorkflowRun failed test"].data.repository.full_name}}`,
},
}))
require.Empty(t, nodeMetadataCtx.Get())
})

t.Run("metadata is set successfully", func(t *testing.T) {
integrationCtx := &contexts.IntegrationContext{
Metadata: Metadata{
Expand Down