Skip to content

Commit

Permalink
fix: moved collection of github PR url until after it is possibly set
Browse files Browse the repository at this point in the history
  • Loading branch information
RogWilco committed Oct 16, 2024
1 parent a081a0d commit 6db8428
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions internal/actions/runWorkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func RunWorkflow() error {
if err != nil {
return err
}

if pr != nil {
os.Setenv("GH_PULL_REQUEST", *pr.URL)
}
Expand Down
13 changes: 7 additions & 6 deletions internal/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ func EnrichEventWithEnvironmentVariables(event *shared.CliEvent) {
if ghActionVersion != "" {
event.GhActionVersion = &ghActionVersion
}

ghPullRequest := os.Getenv("GH_PULL_REQUEST")

if ghPullRequest != "" {
event.GhPullRequest = &ghPullRequest
}
}

func enrichHostName(event *shared.CliEvent) {
Expand Down Expand Up @@ -130,6 +124,13 @@ func Track(ctx context.Context, exec shared.InteractionType, fn func(ctx context
// Execute the provided function, capturing any error
err = fn(ctx, runEvent)

// Populate event with pull request env var (available only after run)
ghPullRequest := os.Getenv("GH_PULL_REQUEST")

if ghPullRequest != "" {
runEvent.GhPullRequest = &ghPullRequest
}

// Update the event with completion details
curTime := time.Now()
runEvent.LocalCompletedAt = &curTime
Expand Down

0 comments on commit 6db8428

Please sign in to comment.