diff --git a/pkg/integrations/github/common.go b/pkg/integrations/github/common.go index af37587f1f..f9f2969df8 100644 --- a/pkg/integrations/github/common.go +++ b/pkg/integrations/github/common.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "regexp" "slices" "strings" @@ -13,6 +14,8 @@ import ( "github.com/superplanehq/superplane/pkg/crypto" ) +var expressionPlaceholderRegex = regexp.MustCompile(`(?s)\{\{.*?\}\}`) + type Repository struct { ID int64 `json:"id"` Name string `json:"name"` @@ -34,6 +37,9 @@ func ensureRepoInMetadata(ctx core.MetadataContext, app core.IntegrationContext, if repository == "" { return fmt.Errorf("repository is required") } + if expressionPlaceholderRegex.MatchString(repository) { + return nil + } // // Validate that the app has access to this repository diff --git a/pkg/integrations/github/create_issue_comment_test.go b/pkg/integrations/github/create_issue_comment_test.go index a9848f1548..46ebe27256 100644 --- a/pkg/integrations/github/create_issue_comment_test.go +++ b/pkg/integrations/github/create_issue_comment_test.go @@ -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{