From 55188acc5d5a820078d20912e24e00107cac2835 Mon Sep 17 00:00:00 2001
From: "Giau. Tran Minh" <12751435+giautm@users.noreply.github.com>
Date: Thu, 2 Jan 2025 13:32:00 +0700
Subject: [PATCH] circleci: fixed panic on master branch (#293)

---
 atlasaction/circleci_action.go | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/atlasaction/circleci_action.go b/atlasaction/circleci_action.go
index 5184474a..38f4dab8 100644
--- a/atlasaction/circleci_action.go
+++ b/atlasaction/circleci_action.go
@@ -107,10 +107,12 @@ func (a *circleCIOrb) GetTriggerContext(ctx context.Context) (*TriggerContext, e
 		if err != nil {
 			return nil, fmt.Errorf("failed to get open pull requests: %w", err)
 		}
-		tc.PullRequest = &PullRequest{
-			Number: pr.Number,
-			URL:    pr.URL,
-			Commit: pr.Commit,
+		if pr != nil {
+			tc.PullRequest = &PullRequest{
+				Number: pr.Number,
+				URL:    pr.URL,
+				Commit: pr.Commit,
+			}
 		}
 	}
 	return tc, nil