@@ -38,7 +38,6 @@ const (
3838 githubWorkflow = "GITHUB_ACTION"
3939 githubAPITokenKey = "GITHUB_TOKEN" // #nosec G101
4040 githubSHAKey = "GITHUB_SHA"
41- githubRefKey = "GITHUB_REF"
4241
4342 githubOwner = "githubOwner"
4443 githubRepository = "githubRepository"
@@ -53,7 +52,6 @@ Auto-generated report for ${jobName} job build.
5352
5453Link to failed build: ${linkToBuild}
5554Commit: ${commit}
56- PR: ${pr}
5755
5856### Component(s)
5957${component}
@@ -66,7 +64,6 @@ this issue is open, will be added as comments with more information to this issu
6664 issueCommentTemplate = `
6765Link to latest failed build: ${linkToBuild}
6866Commit: ${commit}
69- PR: ${pr}
7067
7168${failedTests}
7269`
@@ -150,7 +147,6 @@ func getRequiredEnv() (map[string]string, error) {
150147 env [githubRunID ] = os .Getenv (githubRunID )
151148 env [githubAPITokenKey ] = os .Getenv (githubAPITokenKey )
152149 env [githubSHAKey ] = os .Getenv (githubSHAKey )
153- env [githubRefKey ] = os .Getenv (githubRefKey )
154150
155151 for k , v := range env {
156152 if v == "" {
@@ -252,20 +248,21 @@ func templateHelper(env map[string]string, r report.Report) func(string) string
252248 trimmedModule := trimModule (env [githubOwner ], env [githubRepository ], r .Module )
253249 return getComponent (trimmedModule )
254250 case "commit" :
255- return env [githubSHAKey ]
256- case "pr" :
257- ref := env [githubRefKey ]
258- parts := strings .Split (ref , "/" )
259- if len (parts ) == 4 && parts [1 ] == "pull" {
260- return "#" + parts [2 ]
261- }
262- return fmt .Sprintf ("N/A (github_ref: %q)" , ref )
251+ return shortSha (env [githubSHAKey ])
263252 default :
264253 return ""
265254 }
266255 }
267256}
268257
258+ // shortSha returns the first 7 characters of a full Git commit SHA
259+ func shortSha (sha string ) string {
260+ if len (sha ) >= 7 {
261+ return sha [:7 ]
262+ }
263+ return sha
264+ }
265+
269266// CreateIssue creates a new GitHub Issue corresponding to a build failure.
270267func (c * Client ) CreateIssue (ctx context.Context , r report.Report ) * github.Issue {
271268 trimmedModule := trimModule (c .envVariables [githubOwner ], c .envVariables [githubRepository ], r .Module )
0 commit comments