Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions pkg/integrations/github/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"regexp"
"slices"
"strings"

Expand All @@ -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"`
Expand All @@ -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
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